Autor Wiadomość
zvswgogna
PostWysłany: Wto 22:20, 21 Sty 2014    Temat postu: Dynamically enabling and disabling collision detec

Dynamically enabling and disabling collision detection of an object
I was wondering what is the best way to enable and disable collision detection.
What I need to do is for some world objects to be passable (no collision) by the player at certain times, and impassable (has collision detection) at other times. My world objects are triangle meshes and the player are made out of primitive boxes as the collision skin.
The only way I can see of doing this is to add and remove the collision skins in the physics system depending on what I want,[url=http://www.floware.fr]michael kors paris[/url], but I am afraid I will get some performance issue. Also, I don't want the passable object to turn back on its collision detection when a player is still inside the object. If I remove the collision skins from the physics system, then there's no way for me to test whether the player is inside a disabled collision skin.
Any suggestions as to how I may be able to approach this problem?
Walking through the engine code a bit, I thought I had find the solution but it's not working as I thought it should.
What I've found out is the CollisionSystem class has this DetectAllCollisions method that does the collision detection calculation (as far as I could tell). It takes in a list of bodies that are currently active as a parameter and I'm assuming those are the bodies that get detected for collisions. There is a SetActive and SetInactive method for the body objects and I thought if I set the bodies to inactive, the collision detection won't be performed. But I was wrong and even though the bodies are inactive, collision detection is still being calculated.

Powered by phpBB © 2001, 2005 phpBB Group