playMaker

Author Topic: Physics question  (Read 138 times)

megmaltese

  • Sr. Member
  • ****
  • Posts: 300
    • View Profile
Physics question
« on: September 30, 2018, 04: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, 04:56:58 AM by megmaltese »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13526
  • Official Playmaker Support
    • View Profile
Re: Physics question
« Reply #1 on: October 02, 2018, 11:25:10 PM »
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

megmaltese

  • Sr. Member
  • ****
  • Posts: 300
    • View Profile
Re: Physics question
« Reply #2 on: October 03, 2018, 05: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.