Movement 2d unity
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;
public float jumpHeight;
void Start()
{
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
}
if (Input.GetKey(KeyCode.D))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, 0);
}
if (Input.GetKey(KeyCode.A))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, 0);
}
}
}
Also in C#:
- exception handling c# stack overflow
- unity get velocity at point
- asp list box
- what is a protected int c#
- c# xml file builder
- Movement 2d unity
- how to update a project to cross target .net core
- c# split large file into chunks
- c# read a webpage data
- get out of foreach statement c#
- convert string to boolean c#
- unity html get request
- vb.net check if datatable has rows
- unity oncollisionenter2d
- C# resize window without title bar
- player script unity
- how to reduce garbage collection c#
- how to check if an integer is in array c#
- c# multi threading example
- get string character by index c#
- c# communicate with arduino
- unity delete all children
- unity how to add a bullet impact force
- Exception thrown: 'System.FormatException' in mscorlib.dll dates