Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class SmoothChild : MonoBehaviour
- {
- public Transform target;
- public float posDampingTime = 5;
- public float rotDampingTime = 5;
- void LateUpdate ()
- {
- Vector3 fromPos = transform.position;
- Vector3 toPos = target.position;
- Vector3 newPos = posDamping > 0 ?
- Vector3.Lerp (fromPos, toPos, Time.deltaTime / posDampingTime) :
- toPos;
- Quaternion fromRot = transform.rotation;
- Quaternion toRot = target.rotation
- Quaternion newRot = rotDamping > 0 ?
- Quaternion.Lerp (fromRot, toRot, Time.deltaTime / rotDampingTime) :
- toRot;
- transform.position = newPos;
- transform.rotation = newRot;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement