Geeks3D Forums

Tech Forums => General Discussion => Topic started by: Alex on October 08, 2009, 11:17:36 PM

Title: 2D physix
Post by: Alex on October 08, 2009, 11:17:36 PM
Can we limit physics simulation to one plane ?
What would be the nice way to fix object y coordinate ?
Title: Re: 2D physix
Post by: JeGX on October 09, 2009, 05: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.
Title: Re: 2D physix
Post by: Alex on October 10, 2009, 10:38:57 AM
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.