hi i have sphere with rigid-body.after pressing up arrow the ball is moving automatically.i want to move the ball when the time of player holding the arrow key.
but i made a script help moving the ball after i left(touching ) the arrow key.
rigid-body is much needed for me what should i do
using UnityEngine;
using System.Collections;
public class control : MonoBehaviour {
public float moveSpeed = 6.0f;
void LateUpdate(){
Vector3 forward = Camera.main.transform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;
Vector3 forwardForce = forward * Input.GetAxis("Vertical") * moveSpeed;
rigidbody.AddForce(forwardForce);
Vector3 right= Camera.main.transform.TransformDirection(Vector3.right);
right.y = 0;
right = right.normalized;
Vector3 rightForce= right * Input.GetAxis("Horizontal") * moveSpeed;
rigidbody.AddForce(rightForce);
}
}