Using the platformer camera behavior
by Konrad Carstein · in Torque Game Builder · 06/27/2008 (6:23 pm) · 4 replies
Hi, to anybody that is familiar with the platformer camera behavior found at
http://tdn.garagegames.com/wiki/TGB/Tutorials/Platformer/Camera
I have a question about the track force value. From the tutorial it reads:
Track Force: This value determines with how much lag the camera follows the player's movements. 0 is rigid (player and camera move in parallel), otherwise increasingly higher values also decrease the amount of lag seen.
My question is if 0 means rigid, how can you decrease lag from that? I must be misunderstanding because I read the 0 value has having no lag, and the camera moves with the object at the same time. How would I INCREASE the lag? I tried a negative value, but that really seems to freak it out.
My question basically comes from an issue I have where when the player makes rapid movements forward or backwards the camera follows them exactly, causing everything to scroll when it doesn't need to.
Or maybe there is a way I can stop the camera from following at particular times in script?
Thanks for any assistance!
http://tdn.garagegames.com/wiki/TGB/Tutorials/Platformer/Camera
I have a question about the track force value. From the tutorial it reads:
Track Force: This value determines with how much lag the camera follows the player's movements. 0 is rigid (player and camera move in parallel), otherwise increasingly higher values also decrease the amount of lag seen.
My question is if 0 means rigid, how can you decrease lag from that? I must be misunderstanding because I read the 0 value has having no lag, and the camera moves with the object at the same time. How would I INCREASE the lag? I tried a negative value, but that really seems to freak it out.
My question basically comes from an issue I have where when the player makes rapid movements forward or backwards the camera follows them exactly, causing everything to scroll when it doesn't need to.
Or maybe there is a way I can stop the camera from following at particular times in script?
Thanks for any assistance!
#2
Is there a different way I should be changing the direction of the player object so the camera understanding which direction it is facing?
06/28/2008 (11:07 am)
Excellent. Thank you that that clarification. One other thing, when I check the "face player" box and give it an xOffset of 15 the camera seems correctly offset to the right leaving my player slightly left of center. However when I turn him to the left (using flipX()) the camera doesn't offset in the other direction.Is there a different way I should be changing the direction of the player object so the camera understanding which direction it is facing?
#3
%move = $player.moveRight - $player.moveLeft;
is based on whether you have pressed the right or left arrow key. If your movement code is a bit different, then change this section of the behavior to mirror that.
06/28/2008 (1:14 pm)
The behavior moves the scene object to the right or left of the player based on the movement code used in the previous section of the platformer tutorial. This:%move = $player.moveRight - $player.moveLeft;
is based on whether you have pressed the right or left arrow key. If your movement code is a bit different, then change this section of the behavior to mirror that.
#4
06/28/2008 (9:57 pm)
Thank you, that worked perfectly.
Associate Mike Lilligreen
Retired T2Der
A simple way to stop the camera from following would be to detach the camera from the scene object that has the camera behavior. The behavior itself has a detachCamera() function that you can use.