Author Topic: Server collision triggers  (Read 3900 times)

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Server collision triggers
« on: September 07, 2010, 03:42:12 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Server collision triggers
« Reply #1 on: September 07, 2010, 09:20:04 pm »
I...don't get it. Can you elaborate a bit more on that?

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Server collision triggers
« Reply #2 on: September 07, 2010, 11:57:56 pm »
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?

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Server collision triggers
« Reply #3 on: September 08, 2010, 01:24:54 am »
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:
Code: [Select]
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.   

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Server collision triggers
« Reply #4 on: September 08, 2010, 09:21:10 am »
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.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Server collision triggers
« Reply #5 on: September 08, 2010, 11:33:14 am »
just simple objects. 6 floats are enough like the bounding box array of jPCT. minX, maxX, minY, maxY, minZ, maxZ

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: Server collision triggers
« Reply #6 on: September 08, 2010, 12:48:57 pm »
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.


Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Server collision triggers
« Reply #7 on: September 08, 2010, 04:38:39 pm »
exactly. a single point is enough IMHO. feet or body center