Rotate object A based on camera y rotation if angle is grather or less then
Hello, i want to rotate the belt object only if the camera object goes out of range between X and Y angle.
Right now the belt is fixed to the rotation of the cameraRotate.y
I have done some reasearch and found Vector3.sqrMagnitude, i know that this will help me find the position between 2 game objects can it be also used to find the anle ? or should i use the eulerAngle, if so how should the syntax be to put it in an if statment to make it update only after the camera reaches an angle which is grather on less then the last time it was updated ?
public GameObject Camera;
public GameObject Belt;
public float DistanceToGround;
public float DistanceToForward;
public Vector3 cameraPosition;
public Vector3 cameraRotate;
private void FixedUpdate()
{
cameraPosition = Camera.transform.position;
cameraRotate = Camera.transform.eulerAngles;
Belt.transform.position = new Vector3(cameraPosition.x, cameraPosition.y - DistanceToGround, cameraPosition.z - DistanceToForward);
Belt.transform.eulerAngles = new Vector3(Belt.transform.eulerAngles.x, cameraRotate.y +90, Belt.transform.eulerAngles.z);
}
Your answer
Follow this Question
Related Questions
Using a camera as a child on box collider with MouseLookPlus, which way is up with euler angles? 0 Answers
Problem rotating camera on negative z axis 1 Answer
Using DampSmooth in EulerAngle is affecting the Position.Z value of the gameObject. 0 Answers
2D Weapon Rotation Behaviour Changes on Flipping Sprite? 1 Answer