- Home /
My Water Or My Camera?
I have a problem with this script
var target : GameObject;
var distance = 3.0;
var height = 3.0;
var damping = 5.0;
var smoothRotation = true;
var rotationDamping = 10.0;
function LateUpdate () {
if (target == null)
{
target = gameObject.Find("Fire1(Clone)");
height = 6;
distance = 10;
damping = 25.0;
rotationDamping = 10.0;
smoothRotation = false;
}
var wantedPosition = target.transform.TransformPoint(0, height, -distance);
transform.position = Vector3.Lerp (transform.position, wantedPosition, Time.deltaTime * damping);
if (smoothRotation) {
var wantedRotation = Quaternion.LookRotation(target.transform.position - transform.position, target.transform.up);
transform.rotation = Quaternion.Slerp (transform.rotation, wantedRotation, Time.deltaTime * rotationDamping);
}
else transform.LookAt (target.transform, target.transform.up);
}
when i set the damping between 1-100 my gameObject is shaking, but if i use higher than 100, my water is shaking! what wrong with my script? And when i use FixedUpdate not Update or LateUpdate then my gameobject go with high Speed , my gameObject slowly keep off from my camera. What should i do? How Can i Fix It?
The main problem i see is with your lerp and slerp functions. t should be going from 0(start position) to 1(end position). Currently your t stays fixed at a fixed value (Time.deltaTime*someValue).
can you make an example script from my script, so i know where the error come from. i`m not understand about your statement. Sorry to bother you
thank for all comment. now i know my problem is not in my Water, But in my camera. Because my camera just look to my character that have a Rigidbody Tensor. Thanks all