Jump to content
  • Advertisement
Sign in to follow this  
Doggan

Doors!

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am looking for some basic theory on how you all go about implementing doors in your engines. In my application, they will be scripted in a sense. In my config file, I specify the location of a "door event" (the location is specified so that it falls on a .3ds model button or switch within the scene). So, when the button is clicked, it triggers the event associated with that button, which takes me to a doEvent() function. So that is how I trigger the event. The problem is this: The door cannot be modeled directly into the main .3ds scene, because you cannot just move one part of the scene like that (You can only turn on 'animate' for the entire scene at once). My initial idea for a solution is just to have a door class (that I can derive into different types of doors - sliding, hinged, etc), that has it's own door .3ds model. The orientation of this model will be specified in my script file so that it lines up correctly with the main scene. Now, when the event is triggered, I look for the associated door class, and LERP it between some start/end values (both possibly specified in the script file)... So, the door is an entirely separate entity from the scene, and it is tied directly to some event. It will be a tad of a headache to line up correctly w/ the scene (trial and error), but I don't really see any way around that. This was my first and only idea on how to implement this so far. I'm wondering if any of you have some suggestions/thoughts on how to do this. I am trying to keep my script files as simple as possible. Thanks in advance! :)

Share this post


Link to post
Share on other sites
Advertisement
You could use bounding objects or even the door-meshes themselves to situate the models in the scene in your modeler. You just need to have a method of determining which objects are placeholders and which are scene objects.

It could be as simple as prefixing the name of the object. ENTITY_Door1. Or perhaps include the object's name in the title. ENTITY_WoodenDoor1.mesh. This way your engine can look for this prefix, then use the text that follows to load in the scripted object.

Do you plan to actually animate characters to interact with doors, or do the usual stand-still, door-opens thing? This has nothing to do with the problem, I was just curious.

Share this post


Link to post
Share on other sites
In my world doors are just another type of item. The level file stores a list of items in the world and includes type, position and orientation. The door type is declared in another file I have that defines all thing types giving them a model, a script, et cetera. From there I just put an "OnActivate" in the script and my event system deals with it. I suppose you could change that to "OnClick" or whatever. Within that script function I animate the door.

To recap:
-Position and Orientation of doors in level file
-Model and script information in thing type file
-Event system
-Opens went the appropriate event is fired

Share this post


Link to post
Share on other sites
I have generalized triggers in my engine, that are represented in the map as invisible OOBBs.

Touching or leaving a trigger causes a state machine to be kicked off for that trigger ( usually just spawns an event, but the trigger may want to timeout, toggle on/off, or kill itself ).

For doors, the triggers would be placed in front of the door on the floor, or perhaps surrounding the door object, and would have their state machines notify the door of an object nearby. The door itself would handle tracking its own open & close states, etc.

Another thing with doors is that I plan to light the level & generate the navigation info with all doors open. Doors will be able to cast shadows, so that light doesn't always come through a doorway. Actually the same with all other dynamically moving objects.

Share this post


Link to post
Share on other sites
Thanks for all the feedback. I guess I was on the right track as my original idea sounds similar to some of yours.

Quote:
Original post by Jiia
Do you plan to actually animate characters to interact with doors, or do the usual stand-still, door-opens thing? This has nothing to do with the problem, I was just curious.


This is for a virtual reality project I am working on. So, to answer your question: the character isn't actually rendered so no, he does not interact with the scene. The only interaction now is through a 'wand' object that can be used to click on objects. Hence the switch to open the door. No 'collision detection', in the traditional game sense, can be done so there will never be 'true' interaction.

Share this post


Link to post
Share on other sites
I use a base object class that represents all types of interactive objects in the game, door would be a subclass of this. So when the user presses the interact button it calls the doors trigger method, which handles all event resolution, animation, and any object specific script. As for placement I would go with something like Jiia's suggestion where the scene modeler program allows for the placement of objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!