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

strange behavior with character movement using ApplyImpulse

Discussion in 'Physics Previews' started by Vares, Oct 11, 2019.

  1. Vares

    Vares

    Joined:
    Aug 20, 2017
    Posts:
    3
    My character jumps when I accelerate it using ApplyImpulse.
    The same behavior happens using PhysicsVelocity.

    Code (CSharp):
    1.  public void Execute(ref PhysicsVelocity velocity, ref PhysicsMass mass, ref Translation translation, ref Rotation rotation, ref PhysicsMovementComponent movementParams)
    2. {
    3.     float3 impulse = math.normalize(movementParams.Direction) * movementParams.Acceleration;
    4.  
    5.     ComponentExtensions.ApplyImpulse(ref velocity, mass, translation, rotation, impulse, mass.CenterOfMass);
    6. }

    Is this a bug in the physics system or my error?

    Edit: The effect does not occur with gravity factor 0.
     
    Last edited: Oct 12, 2019
  2. yifanchu183

    yifanchu183

    Joined:
    Jul 4, 2019
    Posts:
    41
    Total same question, how you fix it
     
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Would it be possible to get a sample project showing the problem?

    Is this using the CC sample code or all your own systems? ApplyImpulse ultimately just changes PhysicsVelocity anyway. What direction is the impulse being applied? Can you draw it on screen to help with diagnosis (or point out the impulse)?
    Are there issues with local/global reference frame (e.g. are you applying the impulse in local space when the ApplyImpulse function is expecting world space)? If the impulse is pushing the CC into the floor, leading to an interpenetration, then you will get an upward impulse pushing the body out of the floor.
     
  4. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481