View Full Version : Objects that are not affected by Gravity

10-08-2009, 05:04 AM
Hello there.

Im trying to do a flying FireBall. But it schould not act like a normal pysical object that is affected by Gravity. It should just fly strait in the direction that it was fired an explode at a special Range or if it hit something. Till now i only get it working by seting the velocity of the dmm object in every frame. So it flys and flys and flys. Like i need it, but im not shure if there are better ways. I was not able to find a function to set the gravitiy for a single object. Maby it would work if i add a force that is same like the grafity but in the opposite direction? Any ideas?

10-14-2009, 09:31 AM

We unfortunately don't have a way to turn off gravity on specific objects right now. For now, you could do either one of the things you're suggesting, although using AddForce is a bit tricky, and would have to be applied every frame just like the velocity anyways. This is because a force has a one-frame lifetime in DMM.

If the fireball is moving fast, you want to set the OBJECT_FAST_COLLIDER_BIT on the object, which makes it a bit more expensive, but helps alleviate the "bullet through paper" problem.

You might want to handle the fireball as a "driven" object. Confusingly, we also call this kind of object "fixed" (sorry, it's an artifact of history). This means the motion of the object is completely controlled by the user instead of DMM simulation, except other DMM objects respond to it by collision. This can save simulation time and memory, particularly if you use the OBJECT_FIXED_ONLY_BIT. If you go this route, you call Object::SetNodesSingleState to set the NODE_DRIVEN_BIT on all the nodes of the object. Then to move the object, you would call Node::GotoPos or Object::NodesGoToPos to move the fireball each frame. Unfortunately, if you do it this way, you are still calling something every frame; this is because the fireball is not simulated by DMM at all in this case, so you can't rely on velocity to update positions for you.