Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope position delay from parent
#6
(16-05-2018, 01:59 PM)VirtualCucumber Wrote: My movement is in FixedUpdate() 

Code:
public void FixedUpdate()
   {
       Move();
   }

private void Move()
   {
       targetVelocity = canMove ? input * moveSpeed : Vector2.zero;
       float targetXAccelerationTime = input.x == 0 ? decelerationTime : accelerationTime;
       float targetYAccelerationTime = input.y == 0 ? decelerationTime : accelerationTime;
       velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocity.x, ref velocityXSmoothing, targetXAccelerationTime);
       velocity.y = Mathf.SmoothDamp(velocity.y, targetVelocity.y, ref velocityYSmoothing, targetYAccelerationTime);

       rb.velocity = velocity;
       transform.rotation = Quaternion.Euler(0, 0, velocity.x * torque);
   }

This is my movement, simply using Rigidbody velocity.

EDIT:
I could easily Translate the object instead,  just wanted to keep it simple with a small project.

In Unity, the order of events is the following:

- FixedUpdate (0, 1, or more times)
- Animation update
- WaitForFixedUpdate (After Fixed Update in Obi)
- Update (just once)

So if you are moving the object in Fixed Update(), setting the solver update order to "After Late Update" should ensure simulation happens after the object has been translated.

Edit: Also, ObiSolver exposes lots of C# events that are called at particular times during the simulation loop. OnStepBegin, OnStepEnd, OnBeforePositionInterpolation,OnFixedParticlesUpdated... etc. You could insert your code in a delegate to be called during OnStepBegin, which is triggered every FixedUpdate just before starting the simulation step. This way you could still use Fixed Update simulation order.
Reply


Messages In This Thread
RE: Rope position delay from parent - by cubrman - 15-05-2018, 08:02 PM
RE: Rope position delay from parent - by josemendez - 16-05-2018, 02:11 PM