var strength : float = 10.0f;
var damping : float = 10.0;
function Update ()
{
if(Input.GetKeyDown(KeyCode.Mouse0))
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit))
{
var delta = transform.position - hit.point ;
rigidbody.AddForce(delta.normalized * strength, ForceMode.Impulse);
// Look at and dampen the rotation
var lookDirection = Quaternion.LookRotation(hit.point - transform.position);
lookDirection.y = 0;
Quaternion targetRotation = Quaternion.LookRotation(lookDirection,Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * damping);
}
}
}
This is the code i used to let a boat move when clicking on a plane, to keep it look like the boat moves when we create ripple. Force works fine. But there is some problem with the spinning part.
Quaternion targetRotation = Quaternion.LookRotation(lookDirection,Vector3.up);
This part alone says some semi colon error. Please help me in discovering what error it is.. thanks.