Jump to content

My monsters can run through walls


Angelwolf
 Share

Recommended Posts

I'm wondering if anyone can help me out with this.

 

I have some doors in my map which slide upwards to open. I need my monsters to be able to pass through these doors when they are open. I though the way to do this was to un-tick 'Nav obstacle'. This helps in that it then builds the navmesh through the door, but the problem is that the monsters can pass through even when it's closed.

 

I have tried to play around with the collision settings of the monsters but I can't seem to work it out.

 

Anyone know of a way around this?

Link to comment
Share on other sites

Does the door have a physics shape? Use camera:SetDebugPhysicsMode(true) in game or turn on in the editor. What do you have the collision types set to for the door and the monsters? A good reference is the 'AI and Events' tutorial map that shows this exact scenario. In that map's flowgraph you will see that the monster script is not enabled until a pushbutton trigger occurs which may be something you would want to emulate as well.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

You want it ticked, because the door is an obstacle. Check out how its done in the fps template in the events and AI tutorial map.

No, you do not want the door set as a 'Nav obstacle' because then there would not be a path through the door when the navmesh is built. As I mentioned above, the 'AI and Events' tutorial map uses a trigger that enables the monster script (and opens the door) which will allow the monster to start navigating through the door and the scene.

 

Edit - it appears the characters can push through the door when it has mass and/or set up as a physics object using joints. You could set it up so that the mass and script is applied to the door once you want the door to open, but that would be a little more complicated. So the best/easiest way probably is to use the method shown in the tutorial map.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Ok, so basically the only way I can get this to work is to have what used to be referred to as 'Monster Closets'?

 

Although that's useful as I *do* have monster closets in my game, it doesn't help in that the monsters can't walk through the many doors in my levels. Even if there was a way to have the monster open the door himself, that would be fine too (possibly even preferable!) but I've got no idea at all how to do that.

 

Am I right in assuming that your more complex solution is to have the door as an object with a mass of 0, but when the player uses the object the mass is temporarily set to 10 until the joint cycle has completed?

Link to comment
Share on other sites

I hust checked my game which also has a door. The main character has to find a key and then open the door and enter room. The enemy character CAN follow the main character into the room.The door is not a sliding door. The door is loaded and placed by code, not in the editor so navmesh is not a problem.

 

I use c++ but should make no difference.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

loading and placing objects using code IS fairly simple, and when you have written the code for one you can copy and paste it for all the others with minor alterations. Objects that play no active part can be placed in editor.I have a class called "actor" which includes anything that is active in the game. Even a door is an actor.Good luck anyway.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

It appears to be related to the door having mass. Set the door to zero mass, and the monsters cannot go through. This also means a possible work around would require you to not use joints but to use SetPosition() to open / close the doors. But this also means the monsters will walk right through any prop as well unless it was set as a nav obstacle. So yes, it appears maybe something has changed.

 

Edit: Created an example and opened a bug report that shows the issue: http://www.leadwerks.com/werkspace/topic/14323-character-pass-through-objects-with-mass/#entry98210

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

This helps in that it then builds the navmesh through the door, but the problem is that the monsters can pass through even when it's closed.

 

What was your plan around the monster going through the door? Would the physics shape cause it to stop but if the code is telling it to find the path then it'll be running in place against the door while it opens and look kind of bad.

 

A different approach might be to have a trigger on either side of the doors that when a monster enters the trigger you both stop it from moving and open the door. Then once the door is open you continue the monsters movement to it's target. Now you wouldn't have to worry about the physics and you maybe solve a problem of the monster running in place against the door if the physics was on there and it looks a little more scripted and natural? Just an alternative thought.

Link to comment
Share on other sites

Sure there are workarounds but it doesn't really make sense that a character using the navmesh can start walking through any object with higher mass. I could see trying to incorporate a workaround into a map with a lot of objects and characters turn into a real pain. The physics bodies should be colliding and preventing this from occurring and that doesn't appear to be happening. It looks like it reports the collision but doesn't prevent it from passing through. What is interesting is if the object's mass is lower than the character's mass, then the object will just be pushed out of the way which means the collision is happening. But set the object's mass higher, the character walks through it.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I agree, the bug needs to be addressed. Wanted to just make the OP think differently about the greater problem of AI opening a door and how that could work. In his current situation, or maybe even most with dealing with AI, you'd probably never want them walking into a collidable thing and continue walking (from a game standpoint) not able to get by it, but clearly if they do they should collide because that's how physics works smile.png

 

So, it's a workaround to how physics should work, but in my eyes not to how a game, or at least his specific case, should work.

Link to comment
Share on other sites

I was working on a game mechanic a while back where you could put up planks of wood in doorways and if a zombie was chasing the player they would attack the wood plank to destroy it before continuing to chase the player. The way I did it was I made a trigger around the plank(neither a nav obstacle) with a script that would change the zombie's target to the plank, after the plank was destroyed the zombie would retarget the player and continue chasing. You could use the same method for your door to do things like wait or open the door. Finding an alternate route would be more difficult but depending on your level design I think it would still be a possibility.

Link to comment
Share on other sites

I would just do a raycast every half second or so, and if a closed door is hit, switch the AI entity into the "idle" state.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 3 months later...

I believe I have this fixed, for the next build. The values aren't mathematically precise and I had to adjust them a little to get the right behavior.

 

Please let me know if you find situations where this is still a problem in the future.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...