Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

zeppeldep

Newbie
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About zeppeldep

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location:
    Pretoria
  1. Thx!! Doh!!! almost have it now ... 'cept my lerp is wrong ... need to lerp to the target and not AT the target point ... how do I get a point between the current position and the target? //transform.position = transform.rotation * new Vector3 (0.0f, 0.0f, -dist) + target.position; Vector3 checkPos = transform.rotation * new Vector3 (0.0f, 0.0f, -dist) + target.position; if(ViewingPosCheck(checkPos)) transform.position = newPos; else transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime * orbitDamping); } bool ViewingPosCheck (Vector3 checkPos) { RaycastHit hit; if(Physics.Raycast(checkPos, target.position - checkPos, out hit, distance)) if(hit.transform.tag != "Player") return false; newPos = checkPos; return true; }
  2. The plan is two make this available on PC only. Use keyboard to control the helicopter, use mouse to orbit view about helicopter. Problem: The camera is going thru the terrain, it will probably also go thru all meshes Video here shows current nasty... http://youtu.be/SeV_P2RaMoo Here is the scene showing the assets connected to the camera... https://www.dropbox.com/s/s3my1v54oem2gsx/terrainthru.PNG Here is the code .. check the attempts I have made (very badly) .... using UnityEngine; using System.Collections; public class CamMouseOrbit : MonoBehaviour { public Transform target; public float distance = 10.0f; public float xSpeed = 5f; public float ySpeed = 2.5f; public float distSpeed = 10.0f; public float yMinLimit = -20.0f; public float yMaxLimit = 80.0f; public float distMinLimit = 5.0f; public float distMaxLimit = 50.0f; public float orbitDamping = 4.0f; public float distDamping = 4.0f; private float x = 0.0f; private float y = 0.0f; private float dist; void Start () { dist = distance; Vector3 angles = transform.eulerAngles; x = angles.y; y = angles.x; // Make the rigid body not change rotation if (rigidbody) rigidbody.freezeRotation = true; } void LateUpdate () { if (!target) return; Vector3 oPos = transform.position; x += Input.GetAxis ("Mouse X") * xSpeed; y -= Input.GetAxis ("Mouse Y") * ySpeed; distance -= Input.GetAxis ("Mouse ScrollWheel") * distSpeed; y = ClampAngle (y, yMinLimit, yMaxLimit); distance = Mathf.Clamp (distance, distMinLimit, distMaxLimit); dist = Mathf.Lerp (dist, distance, distDamping * Time.deltaTime); transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.Euler (y, x, 0), Time.deltaTime * orbitDamping); transform.position = transform.rotation * new Vector3 (0.0f, 0.0f, -dist) + target.position; // Vector3 newPos = transform.rotation * new Vector3 (0.0f, 0.0f, -dist) + target.position; // newPos.y = Mathf.Clamp(newPos.y,Terrain.activeTerrain.SampleHeight(oPos),0.5f); // transform.position = newPos; // float dist1 = newPos.y - Terrain.activeTerrain.SampleHeight(newPos); // // if(dist1 < 0.5) // { // newPos.y = newPos.y + 0.7f; // } // transform.position = newPos; // Vector3 wantedPosition = transform.rotation * new Vector3 (0.0f, 0.0f, -dist) + target.position; // // //Vector3 bumperRayOffset; // Vector3 back = target.transform.TransformDirection(-1 * Vector3.forward); // RaycastHit hit; // // //if (Physics.Raycast(target.TransformPoint(bumperRayOffset), back, out hit, 2.5f) // if (Physics.Raycast(target.position, back, out hit, 2.5f) // && hit.transform != target) // ignore ray-casts that hit the user. DR // { // // clamp wanted position to hit position // wantedPosition.x = hit.point.x; // wantedPosition.z = hit.point.z; // wantedPosition.y = Mathf.Lerp(hit.point.y + 1.0f, wantedPosition.y, Time.deltaTime * 5.0f); // } // // transform.position = Vector3.Lerp(transform.position, wantedPosition, Time.deltaTime * 5.0f); } float ClampAngle (float a, float min, float max) { while (max < min) max += 360.0f; while (a > max) a -= 360.0f; while (a < min) a += 360.0f; if (a > max) { if (a - (max + min) * 0.5f < 180.0f) return max; else return min; } else return a; } } Please help ... : ( We will braai together when all this comes thru .. : )
  3. I made 2 small changes to the helicopter controls cs code ... no extra key! .. auto accel now disabled, the player can now hover and do other fancy moves ... : )
  4. it's the helicopter in FPSKit_v1.3.5 ..
  5. But!!! I still think I am missing a key or need to add a key ... S will reduce rotor speed... then it starts to raise again... would be great to stay fixed to maintain a constant height / constant hover
  6. Doh! it's S key .... to slow down rotator ... and down key to reverse ...
  7. Somebody must have asked this already, if so, please refer me to the thread/post and I will delete this post. How do players keep the helicopter at the current level or even go lower or land? Thanks : )
×
×
  • Create New...