Hey guys! Im having some issues with the rotating part of my objects. Its moving fine through terrian without rotation, but not with. What happens is that the object starts jump around and shaking when going up a hill or something that is not flat. Here is the rotation code.
//First rotate unit
targetRotation = Quaternion.LookRotation (movement.newPos - transform.position);
step = rotateSpeed * Time.deltaTime;
targetRotation.z = 0;
targetRotation.x = 0;
// Rotate and set bool rotating true
transform.rotation = Quaternion.RotateTowards (transform.rotation, targetRotation, Time.time * step);
rotating = true;
//Check if unit has rotated enough
if(Mathf.RoundToInt(transform.rotation.y) == Mathf.RoundToInt(targetRotation.y)) {
rotating = false;
}
The movement.newPos is the ray hit.point
The more I click the Unit around the worse it gets.. I have read somewhere else about this problem when on rough terrain.. Is there a simple solution to this? Any help on this? Ive spent many hours ons this :S
The setting are RTS game with RTS camera.
↧