Author Topic: 2D physix  (Read 3485 times)

0 Members and 1 Guest are viewing this topic.

Alex

  • Newbie

  • Offline
  • *

  • 15
    • View Profile
2D physix
« on: October 08, 2009, 10:17:36 PM »
Can we limit physics simulation to one plane ?
What would be the nice way to fix object y coordinate ?

JeGX

  • Global Moderator
  • Hero Member

  • Offline
  • *****

  • 583
    • View Profile
    • Geeks3D.com
Re: 2D physix
« Reply #1 on: October 09, 2009, 04:21:11 PM »
Interesting question  ???
hummm let's see... if you set the Y coordinate of actor's velocity and actor's position to 0 maybe you should manage to stick your actors to the Y=0 plane.

Alex

  • Newbie

  • Offline
  • *

  • 15
    • View Profile
Re: 2D physix
« Reply #2 on: October 10, 2009, 09:38:57 AM »
here is that code
Code: [Select]
local z,x,c = HYP_PhysX.GetActorLinearVelocity(body)
HYP_PhysX.SetActorLinearVelocity(body, z, 0, c)
z,x,c = HYP_PhysX.GetActorGlobalPosition(body)
HYP_PhysX.SetActorGlobalPosition(body, z, 0, c)
z,x,c = HYP_PhysX.GetActorAngularVelocity(body)
HYP_PhysX.SetActorAngularVelocity(body, 0.0, x, 0.0)
Runs in every frame.

When objects colide there is slight change in actor`s direction vector, it is no longer in game plane.

But what if there is function `HYP_PhysX.GetActorGlobalOrientation( )` then we could do this
Code: [Select]
local angle, x, y, z = HYP_PhysX.GetActorGlobalOrientation(body)
HYP_PhysX.SetActorGlobalOrientation(body, angle, x, y, z)
And then it can be done in every couple of seconds, not in every frame.

I tried with `HYP_Object.GetDirection` to retrieve current direction vector of body and failed.