I want to try creating a custom Starcraft 2 map with a third-person camera following a unit. A few custom maps with this feature exist already, so I know it’s possible.
How do I do this? Do I need a custom mods file, or can everything be done in the map file?
Answer
The information provided below is from http://www.staredit.net/starcraft2/Third_Person_Camera where you can find out more stuff like WASD triggers and multiple camera options, but the basics for the 3rd person setup is here:
Setting up the Camera Object
Underneath the “Create Camera” Button, you will see a white box with the value “Camera 001” in it, right click it and hit “Modify Properties”. Set the values to the following (Name – Sub – Value – (Description)):
- Angle – Field Of View – 27.996 – (How wide the view is. This will be a 28 degrees view from the left of the screen to the right)
Angle – Roll – 0.0 – (How far to roll the camera from the left to right. Think barrel rolls.) - Depth of Field – Amount – 0.0 – (Unknown, feel free to update the wiki article if you know any information about this value)
- Depth of Field – Depth – 8.0 – (How far the camera sees)
- Depth of Field – End – 8.0 – (The end position of the view from the point of the camera)
- Depth of Field – Start – 0.0 – (The start position of the view from the point of the camera)
- Distance – 4 – (How far the literal camera is from the actual location of the camera. Setting this to 0 results in a FPS (First Person Shooter), around 4 with be a TPS (Third Person Shooter))
- Distance – Far Clip – 300.0 – (The distance from which nothing will be rendered. If anything is farther than this from the camera, it WILL NOT RENDER)
- Distance – Near Clip – .1 – (The distance when nothing will be rendered. If anything is closer than this from the camera, it WILL NOT RENDER)
- Distance – Shadow Clip – 75.0 – (Assuming the distance after which shadows will not be rendered)
- Target – Pitch – 12 – (Pitch of the camera. Pitch is the looking up/down movement)
- Target – X – (Doesn’t matter, this will change every frame of the game)
- Target – Y – (Doesn’t matter, this will change every frame of the game)
- Target – Yaw – 180 – (Yaw of the camera. Think left to right movement that isn’t barrel rolls)
- Target – Z Offset – 1 – (How far the camera is off the ground)
The main value we need here is the Distance – 4. Setting this to 4 will create a third person camera (Although with units other than a marine, you may need to edit this). 0 will create a first person camera. The same goes for the Target – Z Offset – 1. A taller unit will need a higher value to raise the camera up some.
Global Variables
A few global variables are needed, the names and types of which are indicated below (Name – Type – Value – (Description)):
- FaceOffset[8] – Real – 0.0 – (Where each player’s respective units is facing)
- Speed – Real – 0.03 – (The speed at which a unit moves)
- Units[8] – Unit – [EMPTY] – (Stores each player’s respective units)
- PlayerA[8] – Real – 0 – (Stores is the players A key is down)
- PlayerS[8] – Real – 0 – (Stores is the players S key is down)
- PlayerD[8] – Real – 0 – (Stores is the players D key is down)
- PlayerW[8] – Real – 0 – (Stores is the players W key is down)
Set Up Camera Trigger
Set Up Camera
Events
Timer - Every 0.0 seconds of Game Time
Local Variables
Yaw = 0.0 <Real>
CameraFocus = No Point <Point>
Counter = 0 <Integer>
Conditions
Actions
General - For each integer Counter from 1 to 8 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Controller of player Counter) == User
(Status of player Counter) == Playing
Then
Camera - Apply Camera 001 for player Counter over 0.0 seconds with Existing Velocity% initial velocity, 10% deceleration, and Don't Include Target
Camera - Lock camera mouse relative mode On for player Counter
Camera - Turn camera mouse rotation On for player Counter
Camera - Turn camera height smoothing Off for player Counter
Camera - Turn camera height displacement On for player Counter
Else
Camera Update Trigger:
Camera Update
Events
Timer - Every 0.0 seconds of Game Time
Local Variables
Yaw = 0.0 <Real>
CameraFocus = No Point <Point>
Counter = 0 <Integer>
Conditions
Actions
General - For each integer Counter from 1 to 8 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Controller of player Counter) == User
(Status of player Counter) == Playing
Then
Variable - Set Yaw = (Current camera yaw of player Counter)
Variable - Set CameraFocus = ((Position of Units[Counter]) offset by 0.0 towards (Yaw + 90.0) degrees)
Unit - Make Units[Counter] face (Yaw + FaceOffset[Counter]) over 0.0 seconds
Camera - Set the camera bounds for (Player group(Counter)) to (Region((X of CameraFocus), (Y of CameraFocus), ((X of CameraFocus) + 0.01), ((Y of CameraFocus) + 0.01))) (Do Not adjust the minimap)
Else
Attribution
Source : Link , Question Author : Nick Vaccaro , Answer Author : Tom ‘Blue’ Piddock