• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Camera Rotation

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
Hello hivers,

I'm trying to figure out the math on keeping a cam facing a target, from third person behind your hero. As the hero moves by using arrowkeys to move rotational around the target. The cam follows the movement of the hero always facing the target.

How would i figure out that degree for the cam?
 
GetUnitFacing won't help in this case. Why don't you guys read the thread first before posting a reply?

he wants the camera locked on the *target* with the controllable units being the *eye position* of the camera.

What you can do is using a camera target controller to lock the camera on the target and then get the Angle and distance between both units and set the camera rotation to that angle and the viewing distance to the distance between both units plus an additional offset (as you don't want your camera to be inside your unit, but a little bit behind).
I also recommend getting the terrain Z difference between both units to adjust the angle of attack of the camera aswell, for better results with varying terrain height.
You can do that by moving a global "checker" location to the position of the units and check the z value by using the custom script (requires a global real called "z" and a global location called "TestLoc"):

set udg_z = GetLocationZ(udg_TestLoc)

If the units are able to fly, you should also take the unit's fly heights into account.
 
@zwiebelchen
I never post without reading.

It can be done with unit facing but yes it does need the lock on target which may make it work differently. But if he moves the camera every .03 seconds anyways he shouldn't need the lock on target.
Please elaborate how it could be done with unit facing. What he describes is 100% independant of what the units are currently facing.
 
Level 11
Joined
Jun 30, 2008
Messages
580
GetUnitFacing won't help in this case. Why don't you guys read the thread first before posting a reply?

he wants the camera locked on the *target* with the controllable units being the *eye position* of the camera.

What you can do is using a camera target controller to lock the camera on the target and then get the Angle and distance between both units and set the camera rotation to that angle and the viewing distance to the distance between both units plus an additional offset (as you don't want your camera to be inside your unit, but a little bit behind).
I also recommend getting the terrain Z difference between both units to adjust the angle of attack of the camera aswell, for better results with varying terrain height.
You can do that by moving a global "checker" location to the position of the units and check the z value by using the custom script (requires a global real called "z" and a global location called "TestLoc"):

set udg_z = GetLocationZ(udg_TestLoc)

If the units are able to fly, you should also take the unit's fly heights into account.

Thank you for the help!

I'll go ahead and try this and post what I make.

Also, Zwiebelchen is correct, I can't use unit facing because the facing can change for both units, also I know of that system and has nothing to do with what I am asking.
 
Status
Not open for further replies.
Top