- Home /
Is it possible to make enemies Open doors?
Prety straight forward question. In my FPS game I'm working on I want to have one of my "Alien Zombies" start off in a little outhouse (Sounds strange I know) but the out house has a door and I'm wondering if after he chases my FPS player and say for some reason I don't have a gun so I run away and get out of range I'm wondering if there is a way to make him return to the Outhouse but he would need to open the door. is that possible for enemy AI? and if so how would I script that? I guessing Raycast or maybe a box collider that only my Alien Zombie triggers somehow?
Answer by Justin Warner · Apr 02, 2011 at 02:08 PM
Um...
Call of Duty 2 had their AI actually have an animation of "kicking" the door open...
But really, just have an animation of either, the door opening (You can have him open the door or you don't need to... It's really a matter of preference assuming that the player can't even see it)...
To actually have this happen... Use the AI system, I'd assume you have a target variable, so instead of going to player, make him goto outhouse, if he collides with the house, then the door opens, and he can go in to it... Alternatively you can remove the collider on the door on collision, (Or where ever the zomby collides with it), and so he just keeps walking towards it...
Their's a lot of ways to go about this lol.
Would a Waypoint not work better for making him return to the outhouse after giving up chasing my FPS player when he gets out of range. And lets say my player turns and waches to see where my Alien Zombies goes to, then he would actually need to see him open the door. BTW my outhouse does have an open and close door animation which my FPS player makes work very easily using raycasts when at a certain distance from and only faceing the door. Wondering if the same technique can be used for my Zombie to open the door?
Answer by AngryOldMan · Apr 02, 2011 at 02:37 PM
if your not seeing the zombie go back to the outhouse then add a layer to the collider on the door. Make sure that the player can't go through this layer but the zombie can. It's the quickest method involves no scripting, layers are similar to tags (also to the left of the tag sectoin in the inspector) and they are incredbly useful for controlling specific collisions, eg if you have an invisible wall which you want to be able to shoot through but not let the player walk through, or if you have a door which an enemy can walk through but your player cant walkthrough (just like your situation) :)
Hmmm I think I understand some of what yur saying. Currently my FPS player can open the door and even hide inside of the outhouse if it's unocupied by Alien Zombie that is lol But if my Zombie atarts off in there and my player opens the door without a gun, sees the Zombie, Runs away, Zombie gives chase untile my Player is out of range, then returns to the outhouse (Waypoint needed I guess)? If my player turns to watch and see where he goes then he would need to see him open the door and not pass through it. So I'm wondering how that could be done?
Your answer
Follow this Question
Related Questions
Check lenght from player? 2 Answers
Problem with the movement of AI 1 Answer
Make an object move towards a Player 1 Answer
Getting my guard AI to detect fellow guards 0 Answers
How do you make a enemy AI hear approaching footsteps? 2 Answers