Search Unity

Code not working?

Discussion in 'Scripting' started by joshisawesome6, Oct 24, 2014.

  1. joshisawesome6

    joshisawesome6

    Joined:
    Oct 24, 2014
    Posts:
    1
    The guy in the video made it look easy and I'm pretty sure I did it all right but when I press W A S D or any of the arrow keys nothing happens (I did hit play). Anyone know why?


    using UnityEngine;
    using System.Collections;

    public class NewBehaviourScript : MonoBehaviour
    {
    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");

    Vector3 movement = new Vector3(moveHorizontal, 0.0F, moveVertical);

    rigidbody.AddForce(movement);
    }
    }
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,413
    Is the script attached to that object ?
    Or are there any errors in the console?

    Which video it is?