Hi!
I am a beginner for Unity. I just start to learn it from roll a ball tutorial video. I followed every step it told me to do. But at the end, when I click play, the ball kept rolling forward and leftward simultaneously without pressing up and left key buttons. Is there any problem with code or something?
I want the ball stays at origin point at play mode so i can control it with directional key
Thanks.
Below is my code
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
}