Collisions and Triggers - the eternal struggle
by Chris Hoopes · in Torque Game Builder · 01/28/2013 (6:18 pm) · 4 replies
I'm creating a game in which the player is going to be interacting with the environment in a lot of ways. Some examples include throwing switches to open doors, calling elevators by standing on platforms, operating computer terminals found throughout the game, etc. To that extent a combination of behaviors and triggers has been working great for me. I'm able to alert the player as to when an action is required and everything feels nice and snappy.
The problem comes in instances when the player is standing inside of (colliding with) a trigger while also running up against a wall/platform/projectile/enemy/whatever. The collision detection is laggy and just looks real bad. I've uploaded a video demonstrating the issue to YouTube here where I show a collision with a wall object with no triggers around and then another while standing inside of a trigger. You'll see I'm using the trigger to prompt the user to open the door.
Also in that videos you'll see the player run through a complex elevator area. Here there's a moving elevator platform, multiple triggers for calling the elevator and an area mounted to the elevator where the player can operate it up and down. With all of these triggers the collision goes absolutely haywire and I'm able to fall through geometry and such even though the only thing they're colliding with is the player.
I've tried to implement the excellent scene object collision detection by Andy Hawkins instead of using triggers but the problem is still the same, if the player is colliding with this object then any wall collisions are just going to be plain sloppy. Same goes for mounting buffer objects around the player and seeing if they collide with something instead of just the player. It just seems like if there are multiple collisions there are issues regardless. I've tried upping setCollisionMaxIterations for the player but that doesn't really seem to have an effect on the matter.
And just to give some basis for the project, I have full TGB Pro so I can make source changes and I've been building this off of the PSK Pro. Honestly this is the final nagging problem I'm having with Torque as the rest of dev getting off the ground has been fairly smooth. If anyone has any ideas or can help in any way I'd love to get this figured out so I can move on and hopefully churn out a great game. Thanks!
The problem comes in instances when the player is standing inside of (colliding with) a trigger while also running up against a wall/platform/projectile/enemy/whatever. The collision detection is laggy and just looks real bad. I've uploaded a video demonstrating the issue to YouTube here where I show a collision with a wall object with no triggers around and then another while standing inside of a trigger. You'll see I'm using the trigger to prompt the user to open the door.
Also in that videos you'll see the player run through a complex elevator area. Here there's a moving elevator platform, multiple triggers for calling the elevator and an area mounted to the elevator where the player can operate it up and down. With all of these triggers the collision goes absolutely haywire and I'm able to fall through geometry and such even though the only thing they're colliding with is the player.
I've tried to implement the excellent scene object collision detection by Andy Hawkins instead of using triggers but the problem is still the same, if the player is colliding with this object then any wall collisions are just going to be plain sloppy. Same goes for mounting buffer objects around the player and seeing if they collide with something instead of just the player. It just seems like if there are multiple collisions there are issues regardless. I've tried upping setCollisionMaxIterations for the player but that doesn't really seem to have an effect on the matter.
And just to give some basis for the project, I have full TGB Pro so I can make source changes and I've been building this off of the PSK Pro. Honestly this is the final nagging problem I'm having with Torque as the rest of dev getting off the ground has been fairly smooth. If anyone has any ideas or can help in any way I'd love to get this figured out so I can move on and hopefully churn out a great game. Thanks!
About the author
Recent Threads
#2
From what I can tell the issue doesn't seem to have anything to do with how many calls are happening at once but rather just figuring out how many collisions are happening either to an object or in the scene in general. Maybe if there were a way to make trigger collisions lower priority? I don't know if that's even possible and I've yet to figure out a way to test if it would do anything.
I guess my other question in this thread would be do I have any other options for triggering actions and such that doesn't blow up physics? Ideally I'd like to get this fixed as it seems that's how triggers are meant to be used but off the top of my head the only other option would be to do a check every engine onUpdate to find the player's position and check to see if he's inside of a trigger's bounds and if so do that action but that seems REALLY hacky and potentially crippling performance wise.
01/29/2013 (11:08 am)
That's not actually what's happening as the player is already never leaving the trigger. His collision polygon is still inside of the trigger so onLeave is never called. If it was then you'd see the prompt disappear from above his head.From what I can tell the issue doesn't seem to have anything to do with how many calls are happening at once but rather just figuring out how many collisions are happening either to an object or in the scene in general. Maybe if there were a way to make trigger collisions lower priority? I don't know if that's even possible and I've yet to figure out a way to test if it would do anything.
I guess my other question in this thread would be do I have any other options for triggering actions and such that doesn't blow up physics? Ideally I'd like to get this fixed as it seems that's how triggers are meant to be used but off the top of my head the only other option would be to do a check every engine onUpdate to find the player's position and check to see if he's inside of a trigger's bounds and if so do that action but that seems REALLY hacky and potentially crippling performance wise.
#3
As is my habit I'm guessing blindly.
02/05/2013 (7:34 am)
Perhaps mount an invisible scene object to the player that interacts with triggers instead of using the player? So, use the player for collision and the scene object for trigger callbacks. Perhaps all of the script callbacks happening in the same namespace at the same time is what's causing the problem....As is my habit I'm guessing blindly.
#4
As for namespace, what do you mean? I don't think I've seen anything about namespaces in Torque.
02/07/2013 (6:25 am)
I've tried that and I think I gad the same problems. I'll give it another shot and post the results though.As for namespace, what do you mean? I don't think I've seen anything about namespaces in Torque.
Torque Owner Max Kielland
MK Development
A nice looking game you have there. I'm still only a novice to Torque but one thing that comes to my mind is that it seems like the player is moving in and out from the trigger area. This, I guess, would flood the system with Enter and Leave events.
What if you extend the trigger area to overlap the door so the player will stay inside it?