right mouse drag camera movement
by zackl · in Torque Game Builder · 04/01/2011 (11:55 am) · 7 replies
Hey I am trying to get the camera to move when the right mouse held down.I have it working but the movement is reall quick. I was wondering if anyone knew of a way to do this.here is what I have so far.
function sceneWindow2D::onRightMouseDown(%this,%modifier,%worldPosition)
{
%cursor = %worldPosition;
%curX = getWord(%cursor,0);
%curY = getWord(%cursor,1);
%mouse = %this.getMousePosition();
%this.dismount();
%this.setTargetCameraPosition(%curX,%curY,100,75);
}
function sceneWindow2D::onRightMouseDragged(%this,%modifier,%worldPosition)
{
%cursor = %worldPosition;
%curX = getWord(%cursor,0);
%curY = getWord(%cursor,1);
%this.setCameraInterpolationMode(LINEAR);
%this.setCurrentCameraPosition(%curX,%curY,100,75);
}
function sceneWindow2D::onRightMouseUp(%this,%modifier,%worldPosition)
{
%this.mount($player,"0 0",5,false);
}
#2
04/01/2011 (5:04 pm)
Hey Lonnie thanks for the response. I have tried messing with the interpolation time but it dosn't seem to make much difference.
#3
04/04/2011 (8:53 am)
How about just divide cursor coords by, say, ten?
#4
%worldPosition and it limits the camera view to one area. I need to be able to move around my whole level instead of one area.Do you know of a way to acess the cursor coordinates other than through the
%worldPosition variable?
04/04/2011 (11:01 am)
Hey Rpahut.Thanks for the advice.I have tried that with the %worldPosition and it limits the camera view to one area. I need to be able to move around my whole level instead of one area.Do you know of a way to acess the cursor coordinates other than through the
%worldPosition variable?
#5
use small time fractions like 1/10 of a second or even less.
just an idea.
04/04/2011 (4:48 pm)
add a timer before moving the camera, use a timer check and then move the camera to the cursor position.use small time fractions like 1/10 of a second or even less.
just an idea.
#6
04/06/2011 (11:09 am)
hey Magureanu Laura.Thanks for the advice. I will check it out. I have it working using a helper object that the camera mounts to that way I can use the mount drag to slow down the camera.It works pretty good but the object stutters also causing the camera to stutter.I will try your method and see if it helps.Thanks
#7
In your ondragged you're using setCurrentCameraPosition. Did you mean for that to be a targetPosition?
Try changing that and adding a %this.startCameraMove(%timeDesired) immediately after it.
04/10/2011 (10:28 am)
Zackl,In your ondragged you're using setCurrentCameraPosition. Did you mean for that to be a targetPosition?
Try changing that and adding a %this.startCameraMove(%timeDesired) immediately after it.
Torque 3D Owner Lonnie Shaw
setCameraInterpolationTime(%time)
Purpose
The time camera moves should take. This can be overridden in the startCameraMove() call.
Syntax
%time - Float
The time to take in moving the camera in seconds.
Copied from:
tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneWindow_Camera_Methods