So Guys i’m new to unity and programming overall and with my first game script i encountered some issues
i’m trying to use the rigidody physics with already set inputs to create a controllerscript to control the movement of my player
this is my script
public float Speed;
public Rigidbody2D myRigidbody;
// Use this for initialization
void Start () {
myRigidbody = GetComponent();
}
// Update is called once per frame
void Update () {
if (Input.GetAxisRaw (“Horizontal”) > 0f)
{
myRigidbody.velocity = new Vector3(Speed, myRigidbody.velocity.y, 0f);
} else if (Input.GetAxisRaw(“Horizontal”) < 0f)
{
myRigidbody.velocity = new Vector3(-Speed, myRigidbody.velocity.y, 0f);
} else
{
myRigidbody.velocity = new Vector3(0f, myRigidbody.velocity.y, 0f);
}
}
}
the script is Correct and i don’t get any error message but when i run the game althought i press the L/R arrows the player doesn’t move