unity player code example
Example 1: player script unity
private Rigidbody2D RB;
public float speed = 50f;
void Start()
{
RB = GetComponent<Rigidbody2D>();
}
void Update()
{
if (Input.GetKey(KeyCode.D))
{
RB.AddForce(Vector3.right * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
RB.AddForce(Vector3.left * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.W))
{
RB.AddForce(Vector3.up * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S))
{
RB.AddForce(Vector3.down * speed * Time.deltaTime);
}
}
Example 2: unity
Unity is a cross-platform game engine developed by Unity Technologies.
It is a superb game engine, must use by everyone.
You can create 2D, 3D,VR games with it.
Example 3: unity
GMAER BOIII