Smooth orbit cam without mouse
by Tom Perry · in Torque Game Engine · 02/21/2006 (4:18 am) · 5 replies
I am using the advanced camera resource (good stuff btw, thanks a lot) but I am having difficulty making it turn smoothly. The examples given in the resource use the mouse to turn it and thats fine but I want it to turn without any user imput (it will be based on the relative positions of 2 characters). I have gotten it to turn, but its choppy (i just set the $advCamera::azumith every 10 ms but it looks crap). according to the resource page the update done by Manoel Neto should enable me to tell the camera to start turning and then stop:
"If you set $advCamera::Yaw to 20.0, as example, the camera will start rotating left. Set it to 0.0 to stop rotating."
However setting the $advCamera::yaw value to anything just makes the camera rotate an variable amount of degrees around the player object.
I wonder if it is somthing I'm doing but if anyone can tell me how to get a smooth orbit cam without the use of the mouse it would be greatly appriciated.
"If you set $advCamera::Yaw to 20.0, as example, the camera will start rotating left. Set it to 0.0 to stop rotating."
However setting the $advCamera::yaw value to anything just makes the camera rotate an variable amount of degrees around the player object.
I wonder if it is somthing I'm doing but if anyone can tell me how to get a smooth orbit cam without the use of the mouse it would be greatly appriciated.
About the author
#2
I have not looked at the functionality of the Advanced Camera Resource yet, does it provide "orbit"code support directly or is this something you developed with it?
To be clear, "orbit" is rotation around a point the camera is focused on, like a player unit for example.
While "rotation" would be a rotation around position the camera is pointing away from.
04/19/2006 (10:53 am)
Tom, I have not looked at the functionality of the Advanced Camera Resource yet, does it provide "orbit"code support directly or is this something you developed with it?
To be clear, "orbit" is rotation around a point the camera is focused on, like a player unit for example.
While "rotation" would be a rotation around position the camera is pointing away from.
#3
This is more of an idea, than proven experience - but it could work ;-)0
- Rather than setting the camera to "where you want it to be" every cycle, try interpolating it from "where it is now" to "where you want it to be". This keeps all the movements even and smooth, but still gets the camera where you want it to be eventually.
I'm sure there's other movements handled this way in Advanced Camera so you should be able to find an example.
Also 10ms sounds like a very short amount of time for this, but I could be wrong.
Best of luck,
Steven
04/19/2006 (11:05 am)
Tom,This is more of an idea, than proven experience - but it could work ;-)0
- Rather than setting the camera to "where you want it to be" every cycle, try interpolating it from "where it is now" to "where you want it to be". This keeps all the movements even and smooth, but still gets the camera where you want it to be eventually.
I'm sure there's other movements handled this way in Advanced Camera so you should be able to find an example.
Also 10ms sounds like a very short amount of time for this, but I could be wrong.
Best of luck,
Steven
#4
Yea I am kind of doing that now. I will try to explain what I am doing better.
I have the orbit cam on the player object. I want the camera to orbit around the player to a given azimuth. Now at the moment I do a check for the current azimuth and work out if it is too low, high or close enough that it doesn't need to move. I then + or - the azimuth by one and set a scehdule to check again in X ms (I said 10 above, it can be anything really). Then the whole thing repeats. The azimuth changes keeps moving in steps of 1 degree until it reaches the right angle.
It is choppy at the moment though :( When you use the orbit cam with the mouse it isn't choppy at all, so I just wonder if there is a way to do what it does with the mouse without the mouse.
04/19/2006 (11:28 am)
@ StevenYea I am kind of doing that now. I will try to explain what I am doing better.
I have the orbit cam on the player object. I want the camera to orbit around the player to a given azimuth. Now at the moment I do a check for the current azimuth and work out if it is too low, high or close enough that it doesn't need to move. I then + or - the azimuth by one and set a scehdule to check again in X ms (I said 10 above, it can be anything really). Then the whole thing repeats. The azimuth changes keeps moving in steps of 1 degree until it reaches the right angle.
It is choppy at the moment though :( When you use the orbit cam with the mouse it isn't choppy at all, so I just wonder if there is a way to do what it does with the mouse without the mouse.
#5
04/19/2006 (12:53 pm)
Hmm.. It seems your already more or less doing what I'm suggesting, so I dunno. I haven't actually been in that code in a while. :-( sorry I couldn't be more help.
Torque 3D Owner Tom Perry