I have been following the rolling ball tutorial and I have got a problem with the character moving as soon as the script is ran rather than when the button is pressed like I want it too. Can someone pleas point me in the right direction with this?
using System.Collections;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody> ();
}
void update ()
{
if (Input.GetKey (KeyCode.UpArrow)) {
Vector3 position = this.transform.position;
position.y++;
this.transform.position = position;
}
if (Input.GetKey (KeyCode.DownArrow)) {
Vector3 position = this.transform.position;
position.y--;
this.transform.position = position;
}
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
}
}