Scripting Camera Collision
by John Vanderbeck · in Torque Game Engine · 04/21/2004 (11:06 am) · 6 replies
For the new show tool that i'm writing, I want to allow for object collision, however as we all know the camera just doesn't have collision.
I've been trying to find some way to add in script behaviour to give the camera collision but i've not made any headway. I think i've figured out how to test for some collision on my own, but I can't figure out any way to tie that into the camera. There are no callbacks to allow me to check say whenever the camera is moved. I thought I could do it in whatever code handles the "moveForward" command when the user presses the key, but that doesn't seem to be in script unless i'm missing something. All the code in default.bind does is set a variable $mvForwardAction.
Any tips or suggestions?
I've been trying to find some way to add in script behaviour to give the camera collision but i've not made any headway. I think i've figured out how to test for some collision on my own, but I can't figure out any way to tie that into the camera. There are no callbacks to allow me to check say whenever the camera is moved. I thought I could do it in whatever code handles the "moveForward" command when the user presses the key, but that doesn't seem to be in script unless i'm missing something. All the code in default.bind does is set a variable $mvForwardAction.
Any tips or suggestions?
#2
04/21/2004 (5:38 pm)
Right, I saw all the camera resources, but I can't change the engine code. This has to be script side.
#3
04/22/2004 (6:04 am)
Might could use a castRay?
#4
What about having a scheduled function check to see if the camera has moved and check for collisions there and push back its position if it has collided. That may make for some choppiness though as it wouldn't prevent the initial movement from happening.
The only other thing I could think of is doing some client-to-server communications whenever you wanted to move the camera forward to do collision detection - I don't know how much things would slow down if you did this though.
04/22/2004 (7:03 am)
Just thinking out loud (or in text)What about having a scheduled function check to see if the camera has moved and check for collisions there and push back its position if it has collided. That may make for some choppiness though as it wouldn't prevent the initial movement from happening.
The only other thing I could think of is doing some client-to-server communications whenever you wanted to move the camera forward to do collision detection - I don't know how much things would slow down if you did this though.
#5
@Matthew
Yeah I figure I can do some ray casting to check for collion, but my main problem is WHEN to check for collision. At the time I posted this I could find no way to intercept the move request in order to check for collision.
What i'm thinking now is maybe just write my own function for moving the camera, bind the keys to that, and then I can handle the collision checks in there.
Gotta finish getting my new system up and running first though.
04/22/2004 (7:33 am)
I'm in the middle of upgrading my machine, so dont' have access to my code right now.@Matthew
Yeah I figure I can do some ray casting to check for collion, but my main problem is WHEN to check for collision. At the time I posted this I could find no way to intercept the move request in order to check for collision.
What i'm thinking now is maybe just write my own function for moving the camera, bind the keys to that, and then I can handle the collision checks in there.
Gotta finish getting my new system up and running first though.
#6
04/22/2004 (4:02 pm)
Have you tried looking at the camera's processTick/processMove? That's where collision code is usually done.
Torque Owner Cory Osborn
I guess the only bad thing is if you're trying to implement the new show tool without any engine changes, it won't quite work then. :)
Cory