Is there a way of setting the speed for a camera?
by Tim Saunders · in Torque Game Builder · 11/26/2007 (6:33 am) · 8 replies
I'm doing a RPG where I'd like the screen to scroll as you get near to the edge. The closer you get to the edge of the screen the faster the screen will scroll in that direction. So I really need to be able to set the camera speed in the X and Y directions seperately.
I can only find a function for setting the target position and movement time of the camera. Is there one for setting the speed of the camera as well?
I can only find a function for setting the target position and movement time of the camera. Is there one for setting the speed of the camera as well?
About the author
#2
Thanks for the reply. I'm really looking for the ability to pan around the map whilst the player characters stay where they are. That way I can avoid having to make a seperate map screen (since the player can just look around where he has been by moving the camera).
As the mouse gets to the edge of the screen I want the camera to move in that direction.
What is the call to set the speed of the camera move? I can only find the ability to set the time it takes to get to a certain point using StartCameraMove(%time), rather than setting the actual speed.
Also it would be great to set a direction for the camera to move in rather than a target. That way the camera will never catch up with that target point and stop moving, which happens even though the mouse is still at the edge of the screen.
11/26/2007 (10:12 am)
Hi Kevin,Thanks for the reply. I'm really looking for the ability to pan around the map whilst the player characters stay where they are. That way I can avoid having to make a seperate map screen (since the player can just look around where he has been by moving the camera).
As the mouse gets to the edge of the screen I want the camera to move in that direction.
What is the call to set the speed of the camera move? I can only find the ability to set the time it takes to get to a certain point using StartCameraMove(%time), rather than setting the actual speed.
Also it would be great to set a direction for the camera to move in rather than a target. That way the camera will never catch up with that target point and stop moving, which happens even though the mouse is still at the edge of the screen.
#3
There's a couple of ideas that I have, but I have no idea what the results will be. I don't know if you can mount the camera on the cursor, but if you can't you can always mount an object to the cursor then mount the camera to that object. That simple, and you could have a camera that follows the cursor, adjusting the force accordingly.
However, I don't think you want a camera that follows the cursor all the time. Perhaps you could do something in a onMouseMove callback? Check the distance from the player to the mouse and only mount the camera if it is great enough.
11/26/2007 (11:31 am)
Oh, I see what you're saying. Kind of like a Warcraft style camera? I'd suggest doing a search on both the TGB forums and the Torque Developer Network. I didn't find anything on TDN, but you may have more luck than I.There's a couple of ideas that I have, but I have no idea what the results will be. I don't know if you can mount the camera on the cursor, but if you can't you can always mount an object to the cursor then mount the camera to that object. That simple, and you could have a camera that follows the cursor, adjusting the force accordingly.
However, I don't think you want a camera that follows the cursor all the time. Perhaps you could do something in a onMouseMove callback? Check the distance from the player to the mouse and only mount the camera if it is great enough.
#4
It does seem like there should be a way of setting the speed and direction of the camera directly though.
There is a "Setting up the Camera System to Scroll with The Mouse" entry in the Real Time Strategy tutorial in the Torque Developer Network, but unfortunately it is blank.
11/26/2007 (12:50 pm)
Ah good thinking I could create an invisible object where the camera is, then mount the camera to it and move it at a certain speed and in a certain direction when I want to move the camera. When I want to stop I can unmount the camera and delete the object again. Thanks for your help.It does seem like there should be a way of setting the speed and direction of the camera directly though.
There is a "Setting up the Camera System to Scroll with The Mouse" entry in the Real Time Strategy tutorial in the Torque Developer Network, but unfortunately it is blank.
#5
Yeah, I know. The camera move always transitions smoothly (perhaps even exponentially), its hard to get the results you want.
Lol, I saw that too. A bunch of help TDN is!
11/26/2007 (1:05 pm)
No problem. Quote:It does seem like there should be a way of setting the speed and direction of the camera directly though.
Yeah, I know. The camera move always transitions smoothly (perhaps even exponentially), its hard to get the results you want.
Quote:There is a "Setting up the Camera System to Scroll with The Mouse" entry in the Real Time Strategy tutorial in the Torque Developer Network, but unfortunately it is blank.
Lol, I saw that too. A bunch of help TDN is!
#6
It is outdated, but should give you a start.
11/26/2007 (1:42 pm)
Not sure how you guys got to a blank link--might be a typo in a reference somewhere, but the section is available : Scroll with Mouse.It is outdated, but should give you a start.
#8
Are these lines correct?
%xLimitMin = getWord($cameraViewLimit, 0) + (%xMod/2);
%xLimitMax = getWord($cameraViewLimit, 2) - (%xMod/2);
%yLimitMin = getWord($cameraViewLimit, 1) + (%yMod/2);
%yLimitMax = getWord($cameraViewLimit, 3) - (%yMod/2);
The maximums and minimums seem the wrong way around and the camera tends to end up at (0,0). Although it could be me misunderstanding what it's trying to do.
If I change those lines around then I can get it working a bit, but the panAction() function keeps getting called over and over again even without moving the mouse and the screen moves slowly and very jerkily in the intended direction.
11/27/2007 (3:04 am)
Hi thanks for that Stephen. I've tried the code, but I can't get it to work.Are these lines correct?
%xLimitMin = getWord($cameraViewLimit, 0) + (%xMod/2);
%xLimitMax = getWord($cameraViewLimit, 2) - (%xMod/2);
%yLimitMin = getWord($cameraViewLimit, 1) + (%yMod/2);
%yLimitMax = getWord($cameraViewLimit, 3) - (%yMod/2);
The maximums and minimums seem the wrong way around and the camera tends to end up at (0,0). Although it could be me misunderstanding what it's trying to do.
If I change those lines around then I can get it working a bit, but the panAction() function keeps getting called over and over again even without moving the mouse and the screen moves slowly and very jerkily in the intended direction.
Torque Owner Kevin James
Well, you can set the speed of the camera move, though you'd probably be more interested in mounting the camera to the player. There are different settings with mounting that you can tweak, like force n such. Mess around with that, and if that doesn't yield the results you want, let me know.