D) RigidBody.MovePosition
Version vom 23. Oktober 2019, 14:52 Uhr von TomasM (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „'''D) RigidBody.MovePosition''' Similar to transform.position but applied to a RigidBody, it sets the new position of the GameObject. Recommended to use with…“)
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));
}
}