• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Make unit face center of current camera

Status
Not open for further replies.
Level 3
Joined
Mar 23, 2010
Messages
46
I'm trying to make my marine face the center of my camera. It will not work.
So could someone help me out here? I just need some advice on how to make it work. I've already tried many different triggers but can't find anything...
[whisper]Help me...[/whisper]
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Yeh it looks prety tickey to do.

native point CameraGetTarget (int player);
native fixed CameraGetPitch (int player);
native fixed CameraGetYaw (int player);

Start at CameraGetTarget's point
you then use CameraGetYaw (int player); to get the direction the camera is orignating from. You use this to calculate an offset to get targets point that would approximate the cameras origan. 100 units might be pleanty but if you know the camera distance for sure then use that instead.
CameraGetPitch (int player); can be used if you need a Z origan for the camera (like for a face). Again accurate height helps.

Finally, get the angle from the unit point to the estimated camera point and use that as your facing angle. If the distance used to estimate the camera position is too smaler the unit will appear to be facing at some object in the distance infront of the camera. If it is too large, units to the sides of the camera might appear to be facing at something far behind the camera. The approach above would work best if you know how far the camera is from its target or if the target is in the middle of the view.
 
Status
Not open for further replies.
Top