Game Development Community

Camera movement - player world limits

by Martyn · in Torque Game Builder · 04/04/2009 (4:34 am) · 7 replies

Hello,

I have a request if someone could help me in regards to setting world limits. My plan is to have the camera scroll right, I will have done this by mounting the camera to a scene object that will move to the right.

However what I want is for the players world limits to match the camera space, therefore when the camera moves if the player doesnt it would "force" the player to move with it.

I assume this is done with the CameraViewBounds script?

Any help would be great :)

Thank You

About the author

I have been interested in game development for around 10 years, it has always remained a hobby. I am now looking to develop my skills and maybe progress it from a hobby into a 2nd income.


#1
08/05/2009 (12:32 pm)
If I knew the answer I'd tell You, a lot of these Jerks actually know the answer but they won'y tell You, COMMUNITY? YEAH RIGHT?
#2
08/05/2009 (1:33 pm)
@Martyn - Are you attempting a fluid scroller, or something more like a Legend of Zelda game?

@Junior Snow - Please refrain from name calling. When someone knows the answer and discovers a thread, they usually answer. Your insults could drive away people who wish to help the original posters.

#3
08/05/2009 (3:30 pm)
I'm having some trouble understanding what you're wanting to do. When you said that you want the camera to force the player to move, do you mean that your camera is going to be controlled separately from the player? Or maybe the other way around, where the camera stays put and when the player walks off the screen the whole camera shifts to a new "cell" or area where the player is (old school rpg style)?

If we can't help, in the TGB documentation look under t2dsceneWindow and it gives a list of things like:
completeCameraMove()
setCurrentCameraPosition()
mount()
#4
08/05/2009 (3:35 pm)
i think, what he wants is, the camera moves with the player, BUT if the player wanna go back, he wont be able to... its like a "controlled" forced right scrolling. amirite?
#5
08/10/2009 (1:43 am)
Hello,

Fernando Hurtado Jr: Every question i have ever asked has been answered (and i have asked a few :))

Sorry if I did not make things clear :) - I have got the platform kit now so will be looking at getting started with that. The original question was for the camera to move with the player like in any standard platform game, but only moving say to the right and if the player moved to the left the camera would stay still

I assume it would be using if statments and true/false?

Thanks
#6
08/10/2009 (7:13 am)
well... in that case, yeah, you need to add some coding logic for that, there's no stock function with such functionality... but the thing would be something like:

when the player moves right (you should have a move function in wich you condition where the player moves, ok?), then you force the camera to follow the player (either by mounting it to the player, or updating its position every now and then)

when the player moves left, you should calculate how far from the center of the view field the player is, so, if the player is moving from the far right to the left, theres no problem, but if the player is moving from the center to the far left, then at some point (which is the one you MUST calculate) you have to forbid the player to move any further.

thats (one of many) the way it goes... hope it helped you some.
#7
09/18/2009 (6:25 pm)
Hi I have this same problem, exactly,
So I have tied the camera to an object which will sit hidden, behind the level layers, so it appears the camera simply scrolls to the right at Xspeed automatically and forever, until the end of level. I want my player, a plane to be able to move anywhere on screen. He can speed right up to the the front edge, where he can go no further. And the same is said for the back end, a player can choose no velocityX, or left (negativeX) and he will eventually make contact with the back end of the sceneWindow2D.


So my question is what is the code to create that.


I would no doubht be using
onWorldLimit(%this, %limitMode, %limit)
and or
[setWorldLimit(%mode, %minX, %minY, %maxX, %maxY, [%callback = false])

but am a bit perplexed since %limit is essentially setWorldLimit. In that case, if this is true, min and max XY are constantly changing, they are not finite.



I need to work this out a bit more, but if anyone has any insight I would appreciate it.

the basic code I am working with now is
function player::onLevelLoaded
{
%this.setWorldLimit(%mode, %minX, %minY, %maxX, %maxY, [%callback = false])
}

function player::onWorldLimit()
{
%this.onWorldLimit(%this.player, clamp, %limit)
}