Jump to content

Volume Triggers


reddozen
 Share

Recommended Posts

Anyone have a suggestion to the best way to handle something like... inside a building vs outside or swimming vs walking? I'm basically looking for a programmatically cheep way to determine if I'm inside a volume.

 

Calculating distance from origin of the volume container may be too expensive as you would have to also take into account rotations and translations etc, and I cannot rely on a collision detection when entering the volume, or with the floor of the volume since in the water, you could be suspended at any height of the volume.

 

Collision detection will be used for most situation. Where entering the volume changes the state using a 2 box system of staggered boxes for inside and outside triggers. The problem comes when you load into a volume, or are teleported into it. In this case you wouldn't trigger the collision, so I have to come up with a good way to determine volume location as a situational event.

 

Hope this makes since.

Link to comment
Share on other sites

Hi there,

 

Did you tried doing a simple iteration comparing the x and z coordinates of the volume and of the playes?

 

Something like:

 

if ((player.posx > volume.initialposx) || (player.posz > volume.initialposz)){

    trigger some function;

}

Link to comment
Share on other sites

red, I played with something like this a little while ago. Here is an example:

 

Zones Test

 

The 4 green boxes in front, behind, left and right detect entry/exit. The one on the right triggers changes in the blue cube at centre when you enter

 

And here is the thread on the forum:

 

Trigger Zones

 

Hope it helps.

 

cheers, gryff :)

 

 

Link to comment
Share on other sites

Yea, that is basically what I'm hoping to do for the normal case of walking into buildings or leaving them, but it doesn't cover what to do if you logged into the game from inside the building, or if you were teleported into it from outside. I'll poke around with it and see if i can at least make something work.

Link to comment
Share on other sites

it doesn't cover what to do if you logged into the game from inside the building, or if you were teleported into it from outside.

 

red, most of the code has to do with construction of the scene and screen output.

 

The principle is the important issue - attaching a cube to the camera and then finding which zone mesh it intersects with. I worked on it to trigger actions  - like blocks falling on you, gates slamming shut (or in the example changing the appearance of the centre blue block).

 

For the login situation, which I assume means saved data, to me it would be just an issue of setting up a few variables - like currGateNum , inGate etc. Just add these variables to the saved data. Of course integrating that with your login code might be trickier.

 

The Teleport would depend what type of teleport we are talking about. Is it controlled teleport between Gates where again you could use the known position in different zones of each gate and change the currGateNum. Or is the teleport situation more awkward - a Random Teleport Spell cast on a player - might have to have some lookup table to associate position with a presence in a new zone.

 

Hope you post any new code so people can take a look.

 

cheers, gryff :)

Link to comment
Share on other sites

Yea, if I figure something out I'll share. The teleport will be more of a GM type function. I understand your point... It may just be easier to hard code port locations. If you teleport to someone else, then you just inherit their inside / outside / swimming status when you get their location. That's probably what I'll do.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...