Quantcast
Channel: Questions in topic: "rotating"
Viewing all articles
Browse latest Browse all 173

How to make Smoothfollow align with targets local Z rotation?

$
0
0
So I want the camera to smoothly stay behind an aircraft, meaning it will lerp to its target rotation and position (with distance/height offset) over time. I know it has been asked like a thousand times, but I always get a camera movement jitter when the physics based jet moves and rotates. This is the camera-script: public Transform target; public float distance = 6f; public float height = 1.5f; [Range(0f, 1f)] public float lerpSpeed = 0.7f; void LateUpdate(){ transform.position = Vector3.Lerp(transform.position, target.position + (target.forward * -distance) + (target.up * height), Time.deltaTime * lerpSpeed * 60f); transform.rotation = Quaternion.Lerp(transform.rotation, target.rotation, Time.deltaTime * lerpSpeed * 60f); } The standard SmoothFollow is not causing any jitter, however it follows the target at global XZ-plane, meaning it does not rotate when target rotates around its local z-axis (transform.LookAt aswell). How can this be achieved?

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>