Camera movement and "mount"
by Brian Gallops · in Torque Game Builder · 04/10/2009 (7:47 pm) · 11 replies
Hello,
I'm trying to get the camera to follow the main character in the game I am making. I looked in the documentation and mount() caught my eye. Is this the way to go about having the camera attach to the character so they are in the middle of the screen at all times? I've tried something similar to and variations of this:
function %obj.mount(t2dAnimatedSprite, "1 1", 0, true)
but I cannot get the camera to follow. Any advice on this?
EDIT: I figured it out, please disregard/delete this thread.
I'm trying to get the camera to follow the main character in the game I am making. I looked in the documentation and mount() caught my eye. Is this the way to go about having the camera attach to the character so they are in the middle of the screen at all times? I've tried something similar to and variations of this:
function %obj.mount(t2dAnimatedSprite, "1 1", 0, true)
but I cannot get the camera to follow. Any advice on this?
EDIT: I figured it out, please disregard/delete this thread.
About the author
#3
http://tdn.garagegames.com/wiki/TGB/Tutorials/Platformer/Camera
Learner
Edit: Same suggestion
06/02/2009 (10:35 am)
I used this tutorial to try to understand how to move the camera. At the end I did not understand :) but maybe it can help youhttp://tdn.garagegames.com/wiki/TGB/Tutorials/Platformer/Camera
Learner
Edit: Same suggestion
#4
sceneWindow2D.mount($MainCharacter, "1 1",0,1);
Just replace "$MainCharacter" with the object you want the camera to follow. The numbers that follow are for offset of the object. If you need more information regarding mount(), then there is a lovely description here:
http://tdn.garagegames.com/wiki/Torque_2D/Reference_Guide
It goes into a little more detail - it's where I looked to fix my problem. Hope this helps.
06/02/2009 (11:33 am)
Oh sorry, I had forgotten to report that I got it working. Here is what I added to my main.cs file under GameScripts. It goes within the startGame brackets { }:sceneWindow2D.mount($MainCharacter, "1 1",0,1);
Just replace "$MainCharacter" with the object you want the camera to follow. The numbers that follow are for offset of the object. If you need more information regarding mount(), then there is a lovely description here:
http://tdn.garagegames.com/wiki/Torque_2D/Reference_Guide
It goes into a little more detail - it's where I looked to fix my problem. Hope this helps.
#6
^I'm pretty sure that was all I had, it was a while ago when I added it. I put it in /GameScripts/main.cs, which should be your main .cs file that executes all other .cs files you create for your game. Also make sure that $MainCharacter is replaced with your character's name. Let me know if you're still having problems getting that to work.
06/03/2009 (11:11 am)
sceneWindow2D.mount($MainCharacter, "1 1",0,1);^I'm pretty sure that was all I had, it was a while ago when I added it. I put it in /GameScripts/main.cs, which should be your main .cs file that executes all other .cs files you create for your game. Also make sure that $MainCharacter is replaced with your character's name. Let me know if you're still having problems getting that to work.
#8
06/04/2009 (10:38 am)
Did you try using the class name and not the regular name? I noticed you used Firemanplayer, but I believe you need to have the mount put on a class. Try doing it with Firemanclass and see if that works.
#10
Here's the link: http://tdn.garagegames.com/wiki/TGB/Behaviors/Camera_Mount
Hope that helps.
06/08/2009 (5:36 am)
There's a behaviour you can download and take a look at on the TDN site. It allows you to mount the camera to an object and follow it around. You can be lazy and just set the behavior or you can have a look at the file and work out how it was done that way.Here's the link: http://tdn.garagegames.com/wiki/TGB/Behaviors/Camera_Mount
Hope that helps.
Jonathan Pelchat
Default Studio Name
There is a section about making a camera behavior that follow the player. You should be able to understand how to do it in your own project with this.