Jump to content

How to make some kind of "2d physics" ?


AnniXa
 Share

Recommended Posts

I actually programming my first game with LW, and i want it to have some kind of 2d physics, with a pseudo 3d optic (3d meshes but allways seen from same site)

 

is there a easy way to fix all stuff onto a Z row?

i mean can we just set some kind of "2d" mode?

 

my actuall ideas was to pack the whole game into 2 flat plates but this is very dirty,

otherwise i tryed to set every body onto z = 0.0 in every gameupdate, but this can also be not the best solution.

 

is there any easy way to get this out of the box? =)

Whuts wroong?

Link to comment
Share on other sites

You can use CalcBodyVelocity to calculate the velocity needed to keep your entities on z = 0.0. Just use the current position, set z = 0.0 and then calculate the force. Apply the force the command returns to your body and voila. ;)

 

Edit: LW is lightwave, LE is leadwerks :D

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

ty Dadonic, i think i also need to do this in every update?

seems like i not come around doing stuff for all bodys every time ?

:)

 

You can use CalcBodyVelocity to calculate the velocity needed to keep your entities on z = 0.0. Just use the current position, set z = 0.0 and then calculate the force. Apply the force the command returns to your body and voila. ;)

 

Edit: LW is lightwave, LE is leadwerks :P

Whuts wroong?

Link to comment
Share on other sites

Leadwerks physics (or rather Newton physics) is deterministic... meaning its 100% predictable and things will happen the same every time no matter what... So provided that all your bodies are symetrical along the z axis simply ensure that all your force's vectors have z at 0 and ensure everything starts at z=0. I don't think it is actually possible in this case for the z to change at all.

 

I don't see why this wouldn't work as I have never had a random physics jump to an axis I haven't specified. It should stay perfectly spot on.. Guess the only way to find out is to give it a shot...

 

A 'Make 2D' function probably wouldn't work imo because it sounds like your trying to make something that is essentially 3D but plays like a 2D game kinda like 'Valkyrie Profile' which is a 3D side Scroller.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

You could always put two enormous bodies on either side of the plane you are interested in allowing, and constrain objects that way.

 

That is a good idea to. Do that as well to be safe

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

  • 2 weeks later...

You could always put two enormous bodies on either side of the plane you are interested in allowing, and constrain objects that way.

 

Doing this with more than a couple dozen object causes a huge FPS drop.

 

Updating the positions is the way to go. In order to get a speed increase, I first checked if the object moved beyond a minimum threshold, usually "0.1". That way updates to the object happen evey once in a while and not every frame.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...