D) RigidBody.MovePosition
Zur Navigation springen
Zur Suche springen
D) RigidBody.MovePosition
Similar to transform.position but applied to a RigidBody, it sets the new position of the GameObject. Recommended to use with kinematic rigid bodies. When a RigidBody is marked as Kinematic, it will not be affected by collisions, forces, or any other part of Unity´s phisics engine.
public class RigidBodyMovePosition : MonoBehaviour { public float forceMult = 100; private Rigidbody rb; private void Awake() { rb = GetComponent<Rigidbody>(); } private void Update() { rb.MovePosition(transform.position + (transform.forward * Time.deltaTime)); } }