Moving Objects in Unity: Unterschied zwischen den Versionen

Aus hyperdramatik
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 12: Zeile 12:


[[E) RigidBody.Velocity]]
[[E) RigidBody.Velocity]]
'''E) RigidBody.Velocity'''
The velocity vector of the rigidbody. It represents the rate of change of the Rigidbody position.
public class RigidBodySetVelocity : MonoBehaviour
{
    public float forceMult = 200;
    private Rigidbody rb;
    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
    }
    // Update is called once per frame
    private void Update()
    {
        rb.velocity = transform.forward * Time.deltaTime * forceMult;
    }

Version vom 23. Oktober 2019, 14:54 Uhr

Unity : How to move a GameObject in 3D space?

There are different ways to move an object within 3D space with code. Here we go over 5 options:

A) transform.position

B) transform.Translate

C) RigidBody.AddForce

D) RigidBody.MovePosition

E) RigidBody.Velocity