or it should get destroy…plz help me…i am also done with code but sphere is only rolling when i press right button or arrows…and i want it to rotate in only one direction…here is code
var speed :float= 5.0;
private var controller :CharacterController;
controller = gameObject.GetComponent(CharacterController);
private var moveDirection = Vector3.zero;
private var forward = Vector3.zero;
private var right = Vector3.zero;
function Update()
{
transform.Translate(Vector3(0,0,-speed) * Time.deltaTime);
forward = transform.forward;
right = Vector3(forward.z, 0, -forward.x);
var horizontalInput = Input.GetAxisRaw(“Horizontal”);
var verticalInput = Input.GetAxisRaw(“Vertical”);
var targetDirection = horizontalInput * right + verticalInput * forward;
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, 200 * Mathf.Deg2Rad * Time.deltaTime, 1000);
var movement = moveDirection * Time.deltaTime * 2;
controller.Move(movement);
transform.rotation = Quaternion.LookRotation(moveDirection);
if (targetDirection != Vector3.zero)
{
transform.rotation = Quaternion.LookRotation(moveDirection);
}
}
@script RequireComponent(CharacterController)
plz help…