player script unity
//Simple 2D:
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);
}
}
Also in C#:
- exception handling c# stack overflow
- unity oncollisionenter2d
- unity get velocity at point
- convert string to boolean c#
- c# random number between 0 and 1
- how to trim path in C#
- c# get today's date
- how to select time and date in datetimepicker in c#
- unity on mousewheel down
- unity face direction of movement
- application.stop unity
- rotatearound unity
- c# program exit
- get string character by index c#
- c# webrequest cookies
- how do i foreach c#
- instantiate offset unity
- c# split large file into chunks
- unity 2d horizontal movement help
- asp.net c# write string to text file
- how to use more than one condition in ef join
- c# checksum
- variables
- ignore fakeiteasy