- Home /
State-Machine Based Door entity
Hello Everyone,
I'm hoping to get this state-machine based door working today as I've been stuck on it for the past few days and can't seem to get it to ever call it's autoshut method and close automatically after a given delay when the player has exited its trigger volume. I'd really like to finish it off today (at least the base functionality) but can't get over this hurdle, can anyone spot what I'm doing wrong or missing?
I'm also thinking this would be a cool addition to the script wiki if I can get it going. I hope someone spots this as I'm really wondering what I'm doing wrong here. Thanks again for your time and have an awesome holiday!
UPDATE Here is the current iteration of the FSM Door class, I'll keep this link changing from now on, thanks folks!
What it's doing now it acting a little more stable, it's playing its correct animations and switching states properly but doesn't seem to want to follow through with the AutoClose method. I'm probably looking at this a bit too long, so I'll put it down for today and opt to work on some other areas.
Well that's a lot of scripting!
Too much for me to get my head around easily.
Can you Debug.Log the thing to death. Well just the bit's that apply to closing the door. Record Time.time and which parts are being activated where and what time the door should close.
Let's see if we can spot where it's going wrong.
Sure Thing! Just as a heads up anything related to keys can safely be ignored for now =). That will be a whole new hurdle lol. I'll edit this comment (and up top) when I get the Debugs all set up. ( I've been toying with the script since my last post as well).
This won't answer your question but a little advice if you want to take it. Even though your code looks amazing and it is properly done and you are using best practices I would suggest hacking it out first to get it to work properly then optimize and make it look beautiful. With all due respect this is a door code if it takes you 10 hours to write a simple code that could be written in 7 lines you are wasting time on trying to perfect something that can always be done later. But again it looks amazing! but if it does not work it's useless...
A little side note, you should be making a system that can handle any argument so you are not just using this script on one thing. An example is when I was making my door scripts to allow the player to move throughout the map it was pulled from my pick up system where I would pass out a function when something was true and it would either open a door or activate an item or do another function. This was a manager that my $$anonymous$$m loved because all they had to do was drag and drop the true event into the argument and you saved a ton of time. This can be used for anything, doors, chests, items, enemies, dialoge, etc.
//EventScript
if(conditionTrue)
{
getcomponent<trueConditionScript>(); //Place Script in heiracry
getcomponent.trueconditionScriptBool == true;
}
//Condition script
if(trueconditionScriptBool)
{
OpenDoorFunmction();
}