how do i place a wall or object?

sorry if this has been covered, didn’t find anything searching, but probably didn’t use the right terms…

i want to be able to place and remove a wall/object in an environment (sort of like a door that could be opened). is there any example code of this, or what would be the most efficient way to do this?


To some degree I think that this depends on what, specifically, you mean by “placing and removing” an object: are you referring to building a level, spawning objects during gameplay, toggling the presence of an object that was previously or something else?

From your mention of a door, I’m guessing that you’re referring to an object that can be toggled–its presence turned on and off. In that case, if you simply want it to appear and disappear, then the simplest way might be to detach it from the scene graph (using “doorNodePath.detachNode”) (being careful to keep your own reference to it), and then reattach it when you want it to “reappear”.

thanks! i realized actually, the easiest way is to just change the object position as necessary…

unrelated, the object i’m placing is supposed to be a wall that blocks a hallway, but i find when approaching the corner that forms between the wall and the two sides of the hall, at decently high speed, the collision handling gets to be funky - it oscillates between seeing through the wall and seeing the expected scene. any idea of some fix for this?


Which collision system are you using? Panda’s built-in collision, Bullet, PhysX, ODE or some other, perhaps?

For the moment I’m going to assume that you’re using Panda’s built-in system. In that case, am I correct in guessing that you’re using CollisionHandlerPusher to prevent penetration into the walls, and are keeping your own velocity vector for the player’s velocity? If so, two thoughts occur to me:

  1. Panda has a mechanism for dealing with objects moving at high velocity; see here for more information (although I don’t know how current the information on that page is).

  2. Are you updating your velocity vector to reflect the collision with the wall? I’d expect the character to either stop or bounce back slightly on collision; you may want to register a collision event with your collision handler in order to deal with this.