Answers for "good physics based movement"

C#
1

good physics based movement

private Rigidbody rb;

void Start ()
{
	rb = GetComponent<Rigidbody>();
}

void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");

	Vector3 movement = (m_Camera.transform.right*moveHorizontal + m_Camera.transform.forward*moveVertical);

	rb.AddForce (movement * speed);
Posted by: Guest on January-07-2021
-1

good physics based movement

public float speed;

private Rigidbody rb;

void Start ()
{
	rb = GetComponent<Rigidbody>();
}

void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");

	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

	rb.AddForce (movement * speed);
}
Posted by: Guest on January-07-2021

C# Answers by Framework

Browse Popular Code Answers by Language