• 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.

[Trigger] Need help with camra triggers

Status
Not open for further replies.
Level 2
Joined
Nov 4, 2007
Messages
10
i am making a map, and i am trying to make the camra folow a unit. Do any of you know how to make the camra folow a unit so if the unit turns, the camra turns to? please post if you know.
 
Level 8
Joined
Feb 20, 2007
Messages
338
The trigger function you need is:

  • Camera - Set Player 1 (Red)'s camera Rotation to (Facing of (Triggering unit)) over 0.00 seconds
How you use it depends on what exactly you are looking for.

If the unit is moving about the map and will turn unexpectedly, then you need to use that function with the event:
  • Time - Every 0.10 seconds of game time
If you are having your unit going to a region point, then you would need to figure out the timing of your unit reaching that point, or do the event Unit Enters/Leaves a region.

Using it only once and your camera will turn to face the direction the unit is facing when it fires - If you need the camera to turn often you need to fire the command over and over again for each turn.

Unfortunately having it run every 0.10 seconds will lead to wobble. Units (even flying ones) do not run/fly/hover/float move in a straight line, they zig zag across the map - even a perfectly flat map the camera will sway back and forth with each and every single zig and zag.

For a cinematic you will want to set this up to where the camera follows the unit - then for each point that the unit turns you will give the command for the camera to rotate in the facing direction of the unit.
 
Level 2
Joined
Nov 4, 2007
Messages
10
Thank you both but its not exactly what i am looking for.
I dont want the camra to start off right behind the unit, heres how i am trying to get the camras to work:
You chose an aircraft by putting your pilot close to the one you want to fly.
The aircraft then goes to the take off area, were the camra then goes behind the unit.

I can get the camra to lock onto a target and folow it, but the camra doesnt turn wean the unit turns by itself. That FPS is a good trigger set up, but i dont want the players have to turn the camras them selves. I want the camra to turn and folow the unit no matter what.

A good example of what i want is how the camra is done in Bloody Pirates.

:Edit:
The unit thecamra will folow turns wean the person controlling that unit turns it.
So theres really no way to tell wean the unit will turn, it will just happen wean the player owning that unit wants it to turn.
::Edit::
the last edit doesnt show what i have. Thats just wean i need the camra to turn.
 
Last edited:
Level 3
Joined
Oct 11, 2007
Messages
9
Change to about .30 to .40 seconds, any faster creates unneccesary lag :) heres some of my bloody pirates code: (Theres more to it, and you'll need to set the variables and stuff too, but this should get u going)

Player Loop
Events
Time - Every 0.35 seconds of game time
Conditions

Actions
Player Group - Pick every player in CamPlayers and do (Trigger - Run Camera Lock <gen> (ignoring conditions))

Camera Lock
Events
Conditions
Actions
Camera - Lock camera target for (Picked player) to CurrentSelected[(Player number of (Picked player))], offset by (0, 0) using Default rotation
Set Heightoffset[(Player number of (Picked player))] = (Height Offset of GameCameras[(Player number of (Picked player))])
Camera - Set (Picked player)'s camera Height Offset to Heightoffset[(Player number of (Picked player))] over 0 seconds
Set Fieldofview[(Player number of (Picked player))] = (Field of view of GameCameras[(Player number of (Picked player))])
Camera - Set (Picked player)'s camera Field of view to Fieldofview[(Player number of (Picked player))] over 0 seconds
Set FarZ[(Player number of (Picked player))] = (Far Z of GameCameras[(Player number of (Picked player))])
Camera - Set (Picked player)'s camera Far Z to FarZ[(Player number of (Picked player))] over 0 seconds
 
Level 8
Joined
Feb 20, 2007
Messages
338
You will need a couple three possibly four triggers depending on what you want in the end.

You could use the If/then else multiple functions to set your camera per the unit.

If the ground unit is to to have the normal game camera then you would use:

  • Camera - Reset camera for (Triggering player) to standard game-view over 1.50 seconds
Considering all of your functions for the camera are going to have to take place over and over again every 0.5 seconds or so, you will need a trigger that is a timed event that has conditions set to a real integer number

Thus you can have variables sort of like this:

Cam_setting 1
Cam_setting 2
Cam_setting 3

These are set depending on what kind of unit player X selects.

In your second trigger you have:
  • Apply First Person
  • Events
    • Time - Every 0.50 seconds of game time
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • CamSetting Equal to 1
    • Then - Actions
      • -------- Specified for what ever unit type you want --------
      • Camera - Set Player 9 (Gray)'s camera Angle of attack to 340.00 over 0.20 seconds
      • Camera - Set Player 9 (Gray)'s camera Field of view to 500.00 over 0.01 seconds
      • Camera - Set Player 9 (Gray)'s camera Roll to 0.00 over 0.01 seconds
      • Camera - Set Player 9 (Gray)'s camera Height Offset to ((Current flying height of Selected_Unit) + 130.00) over 0.01 seconds
      • Camera - Set Player 9 (Gray)'s camera Distance to target to 350.00 over 0.01 seconds
      • Camera - Set Player 9 (Gray)'s camera Far Z to 6000.00 over 0.01 seconds
    • Else - Actions
That would be your follow behind camera part of the settings.

To set the selected_unit:

  • Selected_Unit
  • Events
    • Player - Player 9 (Gray) Selects a unit
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Triggering unit) is A structure) Equal to False
      • (Triggering unit) Not equal to HERO
    • Then - Actions
      • Trigger - Turn on Camera Rotation <gen>
      • Set Selected_Unit = (Triggering unit)
      • Set CamSetting = 1
      • Camera - Lock camera target for (Triggering player) to (Triggering unit), offset by (0.00, 0.00) using Default rotation
    • Else - Actions
      • Do nothing
This will lock the camera to the selected unit matching the conditions.

If/then/else will allow you to set the camera to different CamSetting values as per the conditions of your unit selected.

The conditions I used here is a building (in which case the last selected unit will determine where the camera is - for you if it is a ground unit in default camera mode the camera will remain in default mode. If you selected from a flying unit then your camera would continue to follow that flying unit.

You can set your own conditions.

If you want the regular camera then you would use:
  • Conditions
    • CamSetting Equal to 0
  • Actions
    • Trigger - Turn off Camera Rotation <gen>
    • Trigger - Turn off Apply First Person <gen>
    • Set Selected_Unit = No unit
    • Camera - Reset camera for (Triggering player) to standard game-view over 1.50 seconds
I have camera rotation set as another trigger because I wanted the camera to rotate slower than the 0.5 seconds of everything else. That was to cover up the way units zig-zag as they move across the map and looks like this:

  • Camera Rotation
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Camera - Set Player 9 (Gray)'s camera Rotation to (Facing of Selected_Unit) over 0.80 seconds
The camera rotates at a slower pace, pretty much disguising the zig-zag facing of units as they run across the map.

For multiple players you would use the Integer A.

If you only have two modes you can pretty much clean this up a lot, perhaps compressing your rotation into the Apply First Person trigger.

EDIT: IT may seem confusing here simply because I am pulling these triggers out of my own may which has 11 cam settings and other camera stuff going on, such as a trigger I call for cinematics which turns off the first person camera allowing me to play cinematic cameras, and a "deselect" trigger which allows me to move about the map as I am testing it to see what is going on elsewhere.
 
Level 8
Joined
Feb 20, 2007
Messages
338
I didn't understand why not use "Unit's rotation", it was given to us to use ...
I never used it so correct me if im wrong x.x

Because I am only locking the camera onto the unit once (upon the selection event) once the camera is locked onto a unit it will follow that unit for the rest of the game or until another unit is selected.

Rotating the camera with that will only turn the camera upon the selection event when we lock the camera. If the unit is facing north and we lock the camera using the units rotation at that time, then the camera will forever face north until we tell it to rotate again.

Telling the camera to lock onto the unit over and over again is not needed, telling the camera to rotate periodically to match the direction the unit is facing is needed.

That was one of the first things I tried, initially in a cinematic where I wanted the camera to follow a running unit above and behind and facing the direction of the unit as the unit dodged between trees.

The camera locked on facing the direction of the unit at that moment, after that the camera continued facing the same direction, even if the unit turned completely around and went the opposite direction.

I am also using the rotation trigger alone because I have a setting where the camera is locked on to a unit, from a distance but I do not want the camera to rotate as the unit turns the unit can move back and forth and the camera keeps the unit in the center of the screen, but does not rotate as the unit turns/rotates.

As for timing all of this camera stuff, I have had the kids test the campaign and sure enough they love the mouse wheel. So locking the camera at x time has been my personal holy grail - LOL.
 
Status
Not open for further replies.
Top