Simplest and Best way to move a Ridgidbody with only one line of code!!

This is the best way to move a Ridgidbody with only one line of code!
Use it!

How to use it:

  1. Create a script.
  2. Remove all the code.
  3. Copy this code below and Paste it in your Script.
  4. Insert your class name. (Name of the Script)
  5. Done!! :):slight_smile:

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)));}}
1 Like

Dear forum staff. “Unlike” button when?

6 Likes

First of all, it’s not one line of code just because you don’t have any newlines in it . Second your code does not even work correctly, for example your translation is not a function of time there for it will differ with frame rate

2 Likes

I have judged this so called ”content” and have found it lacking.

Same.