2.5D physics

Posted By: 3run

2.5D physics - 10/26/10 07:22

Is there any way, to lock physics simulations in some of the directions? For example, how can I move 3D physical objects, only in X and Z coordinates? And lock its Y movement, so they will not move from side to side. Thank you.
Posted By: Liamissimo

Re: 2.5D physics - 10/26/10 08:25

Just put in a while my.y = 0 for example, that locks the Y coordinate. I am using the same in Gravix (nearly, I am having an INVSIBLE | BBOX wall over my level wink
Posted By: 3run

Re: 2.5D physics - 10/26/10 08:48

Setting "my.y" to zero, will not help!! That will only lock the model, but not physics simulations!! I've tried that at once... Invinsible wall may help, but models may stuck...yes, I can set friction to zero, but I need friction for some of the models... I've tried that too as well... I need an other way to lock not models, but physics simulations!
Posted By: Helghast

Re: 2.5D physics - 10/26/10 10:05

if using PhysX, you can use pXcon_add with PH_6DJOINT and change the joint using pXcon_set6djoint and NX_D6JOINT_MOTION_LOCKED.

regards,
Posted By: 3run

Re: 2.5D physics - 10/26/10 10:23

Thank you Helghast. But I'm still using ODE at the moment. Because, to my mind, physX still isn't stable in GS. As well, as A8.
How do I make this with ODE?
Posted By: Quad

Re: 2.5D physics - 10/26/10 10:46

trust TheLiam, he makes a 2.5d physics game, gravix.
Posted By: Liamissimo

Re: 2.5D physics - 10/26/10 10:54

Code:
my.x = 1354;
			if(mouse_left == 1 && levelnr >= 40 && bomb == 0)
			{
				bomb = 1;
				ent_create("bombe_gravis.mdl",ball.x,bombefunc);
			}
			if(key_a || Xbox_Joystick_Raw_X <= -150)
			{
				phent_addcentralforce(ball,vector(0,1750,0));	
			}
			if(key_d || Xbox_Joystick_Raw_X >= 150)
			{
				phent_addcentralforce(ball,vector(0,-1750,0));	
			}
			if(key_w || Xbox_Joystick_Raw_Y <= -150)
			{
				phent_addcentralforce(ball,vector(0,0,1750));	
			}
			if(key_s || Xbox_Joystick_Raw_Y >= 150)
			{
				phent_addcentralforce(ball,vector(0,0,-1750));	
			}


This is my movement code, I added this my.x = 1354; and it works smooth and perfect wink
Posted By: Helghast

Re: 2.5D physics - 10/26/10 13:27

Originally Posted By: 3run
Thank you Helghast. But I'm still using ODE at the moment. Because, to my mind, physX still isn't stable in GS. As well, as A8.
How do I make this with ODE?


To be completely honest with you, this is absolute BS laugh
I have been working lately on a PhysX involved project, and from the start they seem and feel more stable then anything i've ever done with ODE.

Anyway, if you are resetting a physics object every frame using my.x = 0, make sure to disable and enable the physics object as well every frame using phent_enable.

regards,
Posted By: 3run

Re: 2.5D physics - 10/26/10 13:59

To be honest, I've tried physX only when the first beta version of A8 came out. Didn't try it with new version yet)) Is there any other way than locking models X?
Posted By: Helghast

Re: 2.5D physics - 10/26/10 15:37

Originally Posted By: 3run
To be honest, I've tried physX only when the first beta version of A8 came out. Didn't try it with new version yet)) Is there any other way than locking models X?


Yes, like I said in my previous post:

Originally Posted By: Helghast

Anyway, if you are resetting a physics object every frame using my.x = 0, make sure to disable and enable the physics object as well every frame using phent_enable.


obviously, instead of my.x, you can also do my.y here...

regards,
Posted By: Liamissimo

Re: 2.5D physics - 10/26/10 16:06

You do not have to enable it every frame with phent_enable, I posted my code, this works very fine for me. Or did you meant something else?
Posted By: 3run

Re: 2.5D physics - 10/26/10 18:29

TheLiam, "phent_addcentralforce" works only with physical object, that doesn't have gravity, or am I wrong?
I'm not gonna add any torque or force to my physical objects.
I just need them to do not move in Y coordinates, if they for example fall from hight place and rebound from the floor or other objects. Simulation needs to look completely as in a 2D game, but with 3D models.

Helghast, do you mean something like this:
///
while(1)
{
phent_enable(my,0);
my.y = 0;
phent_enable(my,1);
wait(1);
}
/////
If not, please, explain a bit more. Thank you all guys, for helping me out.
Posted By: Superku

Re: 2.5D physics - 10/26/10 19:30

(EDIT: for A7/ ODE: ) You can continuously add a force on its y-component to keep the entity on the x-z-plain, f.i. simply the negative y-distance.
Alternatively, create an invisible map entity with two walls on the left and right side of the x-axis and place it at your physic entity's position each frame (that's how I do it in my sidescroller).
Posted By: Liamissimo

Re: 2.5D physics - 10/26/10 19:31

Man!

Yes, just try it like I wrote it. If you want to use vec_set then you have to phent_enable, but I can tell you it works with my way, really.

And no, addcentralforce works for everything, the manual just says that if there is no friction or gravtitation it will fly there constantly (?) which is logic because there is no friction or gravity wink
Posted By: flits

Re: 2.5D physics - 10/26/10 19:57

oops srry didnt read the whole post
Posted By: 3run

Re: 2.5D physics - 10/26/10 20:54

TheLiam, thank you, I'll try.
Superku, please, explain a bit more about the alternative way, which you use in your project.
Posted By: Superku

Re: 2.5D physics - 10/26/10 21:21

The maximal size (any direction) of my player is ~90 quants.
I've created a map entity consisting of two walls (none or flat texture), some 100 quants in height and width, parallel to the x-axis (I use x/z-movement, too). The y-distance between both walls is 128 quants, so my 90 quants player can freely rotate within these limits.
When my player entity is stunned, I register it for the physics engine and vec_set(wall_map_entity.x,player.x) the position every frame. I only add torque around the y-axis and forces restricted to the x-/z-axis, so it does not look odd when (if ever) the player hits the invisible walls.
Posted By: 3run

Re: 2.5D physics - 10/27/10 08:40

Looks easy and clear. Thank you, I'll give it a try laugh
© 2024 lite-C Forums