Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Moving through doors help please.

Author
Message
Levanthus
20
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 25th Jun 2017 22:33
I've been away from Dark Basic for quite a while due to other projects that have occupied my time and just recently decided to get back to working on a game I had started a while back. Basically, it is akin to MYST or The Stanley Parable sort of thing, a sort of 3D first person point and click adventure and it's all going pretty well so far. NOW the problem I am having involves, as the title of the thread suggests... Moving through doors. As I see it, I have 2 options, I can animate doors and then update the collision boxes so the doors swing open and I can walk through freely, OR I can do the old style "Click on the door and sort of transport instantly to the next room" sort of thing. Now to save on polygons etc, and going for a sort of older style to the game, I prefer the second option, however, I'm struggling to find a way to accomplish this. I'll clarify what I mean.

I have all of the doors as 1 object like I have 3-4 doors all linked into one object so as to save on coding and loading individual objects. So is there a way to click on one part of the object and have it move you forward in the direction you are facing and it locate you into the room beyond said door, and so on with the other doors? I have tried the MOVE OBJECT x,x command, but if the camera is pointing slightly down it drops you through the floor, I'm sure there is a way to do it and it probably involves sin/cos commands etc, and annoyingly, I am hopeless with Trig. I mean literally, all I need to happen is for the player object to move forward by say... 20 in the direction they are facing.

Any help would be greatly appreciated.
Thank you for your time.
I can see from your smile, you\'re not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 7 GB Ram, Radeon HD 4650, 3.6 TB HDD
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 26th Jun 2017 05:19
honestly id just use separate models or make collision boxes but im no expert.
An object with non connected parts. For example "4 doors not connected" are saved as limbs within the model. You can use the limb commands to find out which door your at. make a for loop that cycles through your 4 door limbs take the player position and limb position subtract them to find the distance to door. check distance against your preset range value a value u pick to decide how far away to activate the door. then you simple need to find the player (angleY) to figure out which direction to move based upon current player facing direction.

can do something like this cheating around using yangle and extra wrapvalues ect if ur so worried about code.

A child's dream never dies.





zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 26th Jun 2017 17:18 Edited at: 26th Jun 2017 17:20
my approach:
get the limb number of each door and define a position for each door in each room.
so if the player is in room 1 and clicks on door 1 then position the player on x,y,z in room 2.
if the player is in room 2 and clicks on door 1 then position the player on x,y,z in room 1.
something like that.

this will get messy if the map is hardcoded, but it prevents bugs if the player is standing in an angle in front of the door, where just moving the player forward can make him clip through walls.
you can track the room number with collision commands and invisible objects, or check the position of the player, or instead of checking the room, check the relative position of the player to the door limb.

Levanthus wrote: ""Click on the door and sort of transport instantly to the next room" sort of thing"

in most games that use that approach, the room behind a door is not actually behind that door, but at some other location. mostly because of limited resources.
you can also use that to make a player go into a small house but ends up in a big room.
another reason why i would prefer making fixed spawn points for doors.
if you make each room at another position then the rooms do not share any door object and you can just link a door number with coordinates to move the player.

if you plan on making the game bigger:
smerf wrote: "honestly id just use separate models"

that.
if you make each door a seperate object, and make it so the pivot of the object is somewhere at the door hinges, then you can rotate the door at the y axis to make it move, if you want that.
you can load the object and then make copies of it that share the vertex data. they are individual objects, but you only need to store the object once in the ram. (if all doors look the same).
make up some map file format that can store all the data that you need for your game to work and then write an editor around it, but keep it simple. you don't want to spend more time on the editor than on the game.
a text based editor that can work with simple commands and a 3d view of the world will probably do.
that editor can then manage your doors. as the game gets bigger, you can make the editor better as well.

Login to post a reply

Server time is: 2024-04-14 09:15:51
Your offset time is: 2024-04-14 09:15:51