This is the best way to move a Ridgidbody with only one line of code!
Use it!
How to use it:
- Create a script.
- Remove all the code.
- Copy this code below and Paste it in your Script.
- Insert your class name. (Name of the Script)
- Done!! :)
Code:
using UnityEngine; public class [Insert your class name here!!] : MonoBehaviour { public float moveSpeed = 4f; void Update () { GetComponent<Rigidbody>().MovePosition(GetComponent<Rigidbody>().position + (transform.forward * (Input.GetAxis("Vertical") * moveSpeed))); GetComponent<Rigidbody>().MovePosition(GetComponent<Rigidbody>().position + (transform.right * (Input.GetAxis("Horizontal") * moveSpeed)));}}