Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[Feature request] MovePosition/Rotation internal values

Discussion in 'Physics Previews' started by lightbug14, Nov 12, 2020.

  1. lightbug14

    lightbug14

    Joined:
    Feb 3, 2018
    Posts:
    447
    Hello, sorry if this is not the place for this:oops:.

    I wanted to ask if is it possible to add a simple functionality to the 2D/3D Physics API which returns if a MovePosition/MoveRotation call has been made (boolean) and its associated value (position/rotation).
    For example:
    ScriptA executes first:
    Code (CSharp):
    1. //ScriptA.cs
    2. rb.MovePosition( someValue );
    ScriptB executes after ScritpA:
    Code (CSharp):
    1. ///ScriptB.cs - After ScriptA's FixedUpdate
    2. Vector3 value = Vector3.zero;
    3. bool aCallHasBeenMade = scriptARigidbody.GetInternalMovePositionValue( ref value);
    The problem: After a MovePosition call nothing really changes for the RB, no position change (obviously, we are using MovePosition), velocity, point velocity, nothing. So, What if we want to predict if a rigidbody is going to move? We need to wait until after the simulation :( (rb.velocity does change after that).

    Personally i use a custom RB wrapper to store that MovePosition value ("TargetPosition"). Instead of doing rb.MovePosition( X ) I do customRigidbody.MovePosition( X ):
    Code (CSharp):
    1. public void MovePosition( Vector3 position )
    2. {
    3.     rigidbody.MovePosition( position );
    4.         TargetPosition= position;
    5.  
    6. }

    Note: this same funcitonality can be applied to AddForce as well...Maybe? Same issue, if i call rb.AddForce nothing really changes.


    Regards.
     
    Last edited: Nov 13, 2020