Help with this script

I am new to unity and C# and i copy this script from this website and it doesent work on my player.(it is a player script that makes a static object supposed to move with the arrow keys)
If im missing anything please let me know and where. Or if I have the wrong thing

using UnityEngine;
///


/// Player controller and behavior
///

public class PlayerScript : MonoBehaviour
{
///
/// 1 - The speed of the ship
///

public Vector2 speed = new Vector2(50, 50);

// 2 - Store the movement
private Vector2 movement;

void Update()
{
// 3 - Retrieve axis information
float inputX = Input.GetAxis(“Horizontal”);
float inputY = Input.GetAxis(“Vertical”);

// 4 - Movement per direction
movement = new Vector2(
speed.x * inputX,
speed.y * inputY);

}

void FixedUpdate()
{
// 5 - Move the game object
rigidbody2D.velocity = movement;
}
}

Firstly, use code tags when pasting code.

Make sure this script is attached to the object you want to move and has rigidbody2d component attached.

1 Like