Server collision triggers

Started by zammbi, September 07, 2010, 03:42:12 PM

Previous topic - Next topic

zammbi

I'm stuck a little trying to work out how I will do collision triggers on my server.

So a simple example would be someone walking in a door and warping the user.

Another example would be a user walking in through one aka, to open a door.

Then I will also need to support room size triggers aka security or lava. Which I could have many triggers inside that large trigger.

The triggers will only need to fire once, but some cases I'll need to check if I'm still inside one.

I'm quite lost on how I would tackle this problem. So any help on the subject would be great.

EgonOlsen

I...don't get it. Can you elaborate a bit more on that?

zammbi

Well a trigger would be a set area which something can happen. Say for the door example, you would have one around the door so that when the character walks on it the door would open.

I have written the event system on my game, but I need help in setting up triggers that would fire these events.

What does everyone else do for doors? switches, etc in there games?

raft

in karga i used axis aligned trigger boxes for such actions. using axis aligned boxes determining if a point (such as user) is inside requires at most 6 comparions. ie:
minX <= x <= maxX
minY <= y <= maxY
minZ <= z <= maxZ


this comparision is made every frame or every 5 frame or similar. if user is inside action is triggered. i also set a flag in trigger to avoid continuous triggering. but i suppose this depends on application. mine was for teleporting among nodes so trigger once made sense.

if you need to clear the flag when user goes away from trigger box, this may be a good idea: define a larger box containing the trigger box. if trigger action is set and user is outside of larger box, clear the flag.   

zammbi

Is your trigger boxes object3D objects? or just a made up object

I think I'll have a list of trigger boxes(basic object just holding location and size) in a zone, every time the user moves I'll check if he walks into/out of a trigger. Setting a flag if needed.

How do I get a width, depth and height of a model?

I guess this should be fast enough, though I just wouldn't want too many in one zone or it could slow things down. Unless someone wants to help me work out a efficient array for this kind of thing.

raft

just simple objects. 6 floats are enough like the bounding box array of jPCT. minX, maxX, minY, maxY, minZ, maxZ

zammbi

Oh I understand how you did your formula now. So you checked the box against a point, which could be a point by the characters feet. I guess I don't need to check the whole character and could cheat a little too.

Thanks for sharing.


raft

exactly. a single point is enough IMHO. feet or body center