Tech Forums > General Discussion

2D physix

(1/1)

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

--- 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)

--- End code ---
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: --- local angle, x, y, z = HYP_PhysX.GetActorGlobalOrientation(body)
HYP_PhysX.SetActorGlobalOrientation(body, angle, x, y, z)

--- End code ---
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.

Navigation

[0] Message Index

Go to full version