2D physix

Started by Alex, October 08, 2009, 11:17:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Alex

Can we limit physics simulation to one plane ?
What would be the nice way to fix object y coordinate ?

JeGX

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

here is that code

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

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.