This project has moved and is read-only. For the latest updates, please go here.

Geom vertices question

Nov 12, 2009 at 10:02 PM
Edited Nov 12, 2009 at 10:56 PM

I already posted this on the XNA forums so I'll just quote it:

"Is there any way to keep an object in a fixed position until something hits it? At that point it would move in response to the force of the other object hitting it and gravity would start effecting it as well."

I just got directed to these forums from over there so maybe someone can put me in the right direction. Thanks a lot.

Nov 13, 2009 at 9:10 PM

You can simply set Body.IsStatic = true, then subscribe to the OnCollision event and set Body.IsStatic = false in the event handler (and be sure to return true). That would cause the object to be static until it collided with an object. You could even go one step further and check which object it collided with (by observing the Geom.Tag property of the colliding geom) and respond accordingly; so you could make your object become un-static only when certain other objects collide with it.

I use this in a game I'm working on. Observe the red blocks, they're static until hit by the character.

Nov 14, 2009 at 1:45 AM

Exactly what I needed, thanks a lot, good luck with your game!