Mounting a "slow to react camera" to the player
by Ryan Neighbour · in Torque X 2D · 08/13/2007 (2:29 pm) · 9 replies
Hey all,
I saw a thread about this a couple of weeks ago but now I can't seem to find it. So if someone could link it or can answer that would be great.
Basically what I want to do is have the camera follow the player but lag behind slightly as if it were on a spring.
Thanks in advance folks.
[edit]
Not sure if I should have stuck this in the TX private forum or not so if I should have let me know and I'll head over there.
[/edit]
I saw a thread about this a couple of weeks ago but now I can't seem to find it. So if someone could link it or can answer that would be great.
Basically what I want to do is have the camera follow the player but lag behind slightly as if it were on a spring.
Thanks in advance folks.
[edit]
Not sure if I should have stuck this in the TX private forum or not so if I should have let me know and I'll head over there.
[/edit]
About the author
Just started an M.Sc. in Electrical and Computer Engineering during which I'll be investigating the use of Agent Based Models in the field of Epidemiology. Aside from that, trying to get my first indie project off the ground and having a blast doing it.
#2
08/14/2007 (1:23 pm)
Thanks James. Just tried it and it worked perfectly.
#3
I'm modifying the Space Shooter starter kit to have a zoomed in camera that tracks the player (pretty much exactly like in Geometry Wars). I've mounted the camera to the player, set the mount force, told it to use the mount force, but now the camera rotates with the player's ship.
Does anyone know how to prevent this? I've tried resetting the camera's rotation in the process tick of the player control component using
any ideas?
08/14/2007 (1:58 pm)
Ok, now I have a new question about the camera.I'm modifying the Space Shooter starter kit to have a zoomed in camera that tracks the player (pretty much exactly like in Geometry Wars). I've mounted the camera to the player, set the mount force, told it to use the mount force, but now the camera rotates with the player's ship.
Does anyone know how to prevent this? I've tried resetting the camera's rotation in the process tick of the player control component using
T2DSceneCamera cam = (T2DSceneCamera)(TorqueObjectDatabase.Instance.FindObject("PlayerCamera"));
cam.SetRotation(0, x);I've tried with x = true and x = false (mostly because I haven't looked to deeply into what that actually does) and it didn't work.any ideas?
#4
I wrote a new function
and just called it at the beginning of process tick and interpolate tick.
It doesn't flicker or do anything weird but does anyone know if there's a better way to handle this?
08/14/2007 (2:11 pm)
I've got it all figured out now.I wrote a new function
private void steadyCamera()
{
T2DSceneCamera cam = (T2DSceneCamera)_player.GetMountedObject("PlayerCameraMount");
cam.Rotation = 0.0f;
}and just called it at the beginning of process tick and interpolate tick.
It doesn't flicker or do anything weird but does anyone know if there's a better way to handle this?
#5
08/14/2007 (2:20 pm)
Try: cam.TrackMountRotation = false
#6
Thanks for the tip Dan.
Just as an aside: TX is [edited for content] sweet!
08/14/2007 (2:50 pm)
Bah, I'm blind. I should have payed more attention when I was going through the available functions.Thanks for the tip Dan.
Just as an aside: TX is [edited for content] sweet!
#7
If I simply use:
_camera.Mount(_tracked_object, "", new Vector2(7, -4), 0, false);
or some variant of this line, it works. Once I try to apply MountForce by using:
_camera.UseMountForce = true;
_camera.MountForce = 4.0F;
_camera.TrackMountRotation = false;
_camera.Mount(_tracked_object, "", true);
The camera ceases to mount to the player. Setting the last Mount parameter to false does nothing as well. These are both in the OnRegister method of a CustomCamera component. What am I doing wrong?
07/26/2009 (11:41 am)
I have tried on multiple occasions to get MountForce to work and cannot.If I simply use:
_camera.Mount(_tracked_object, "", new Vector2(7, -4), 0, false);
or some variant of this line, it works. Once I try to apply MountForce by using:
_camera.UseMountForce = true;
_camera.MountForce = 4.0F;
_camera.TrackMountRotation = false;
_camera.Mount(_tracked_object, "", true);
The camera ceases to mount to the player. Setting the last Mount parameter to false does nothing as well. These are both in the OnRegister method of a CustomCamera component. What am I doing wrong?
#8
Not too sure, I haven't used TX in quite some time now. If I get a chance in the next few days I'll see if I can help.
But just so I can try to reproduce it exactly, what version of TX and GSE are you using? (like I said, haven't used it in quite some time so I can't remember if there's just one set that works or not)
08/02/2009 (12:19 pm)
Hey Hey,Not too sure, I haven't used TX in quite some time now. If I get a chance in the next few days I'll see if I can help.
But just so I can try to reproduce it exactly, what version of TX and GSE are you using? (like I said, haven't used it in quite some time so I can't remember if there's just one set that works or not)
#9
08/03/2009 (11:12 pm)
I tried this tonight thinking it would be a cool camera effect, well for me it wasn't however I found that when you do the _camera.Mount it clears the MountForce property. So you have to set the _camera.MountForce after you mount the camera.
Associate James Ford
Sickhead Games