playMaker

Author Topic: Physics question  (Read 1532 times)

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Physics question
« on: September 30, 2018, 07:54:37 AM »
Is there a way to place an action on a PhysX rigidbody BEFORE the physics engine acts on it?
In example, I have a wheel that has a rotation speed of 500 degree per second.
I want to reduce that speed by 90% at the moment of impact, BEFORE the impact takes place.
To be more clear: when to objects collide, I want to execute an action EXACTLY when they collide, but BEFORE the physics engine acts on the bodies.
Is there a way to do this, or is any action taking place AFTER the impact has affected the objects?
« Last Edit: September 30, 2018, 07:56:58 AM by megmaltese »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Physics question
« Reply #1 on: October 03, 2018, 02:25:10 AM »
Hi,

 uhm... I am not sure it's possible no, but I think you may not be using the right api to actuall control that RB.

 how are you currently trying to reduce the angular speed?

Bye,

 Jean

PolyMad

  • Hero Member
  • *****
  • Posts: 545
Re: Physics question
« Reply #2 on: October 03, 2018, 08:53:57 AM »
At the moment I still didn't work on it, exactly because I must gather info on how to deal with this problem first.

From an answer on the Unity forums, a guy told me that the PhysX engine actually has the possibility to place a command on contact, that happens before the body is affected by the engine dynamics, but that Unity does not expose this function.
So I'm afraid I'll have to go with triggers.

On how to do that, I think it will be pretty easy: when the trigger is activated by a collision, I'll set the ANGULAR DAMP on the wheel at 9999 or something like that, for a single frame, so that its speed will immediately drop.

Another way I could deal with this problem, maybe simpler, is to automatically cut the power when the wheel is not touching anything, but I would like to avoid this, I would like to leave total control to the player.