- Home /
Question by
pancakespark · Jan 11, 2018 at 09:47 PM ·
3d
Why does my orb fly diagonally instead of straight?
I feel stupid for asking this, but in the attached gfycat you can see when I turn the orb to the left, it doesn't continue to fly straight with the frame, but rather it moves diagonally to the left. Any tips on how to fix this? Thank you to anybody who can shed some light!
https://gfycat.com/DopeyZestyFlicker
The movement code in question looks like:
void RespondToHorizontalInput() { if (CrossPlatformInputManager.GetButton("Horizontal")) { transform.Translate((Vector3.right HorizontalMovementFactor Time.deltaTime)); transform.Rotate(0, Yaw, 0); }
else if (CrossPlatformInputManager.GetButton("Fire"))
{
transform.Translate((-Vector3.right * HorizontalMovementFactor * Time.deltaTime));
transform.Rotate(0, -Yaw, 0);
}
else
{
return;
}
}
the camera movement looks like: public Transform target; public float smoothSpeed = 10f * Time.deltaTime; public Vector3 offset;
void LateUpdate()
{
Vector3 desiredPosition = target.position + offset;
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
transform.position = smoothedPosition;
transform.LookAt(target);
}
Comment
Your answer