• 🏆 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!

[Trigger] First person camera set-up?

Status
Not open for further replies.
Level 8
Joined
Feb 20, 2007
Messages
338
I have a follow camera which is set up to follow behind a unit at a distance, when the unit turns the camera turns with the unit facing the direction the unit faces.

Sadly every time the unit turns, the camera turns too - sad because the way units like to zig-zag through the map even across open country.

I had the camera set to rotate when the user uses the arrow button say if the player hits the left arrow to turn the unit left then the up arrow to move the unit forward the camera would lock on the direction the unit was facing when the left key was released (the direction the unit turned). The camera would remain in that general direction until the player either used the left or right arrow button (turning left of right) or the down arrow which turns the unit completely around to face the opposite direction and the camera turns as well.

I also tried using the esc button to turn the camera the current direction the unit is facing even while in motion.

However I like to use the mouse, clicking the ground, clicking on units attacking etc. is there a way to set the camera (and of course the unit) to rotate to face the spot where the ground/unit/whatever was clicked?
 
Level 8
Joined
Feb 20, 2007
Messages
338
There is an event that triggers when a unit is selected you know?

From that you can then do your camera angle setting actions.

Tried that. However the camera locks its rotation to the rotation of the unit upon selection. in order to view from behind the unit one would need to select the unit over and over again.

I need the camera to rotate to face the general direction the selected unit is going so the camera follows behind that unit (first person cam) without wiggling back and forth like a drunk as the unit wiggles back and forth walking from point a to point b.

The two images below are from the game. Right now I have the camera following the selected unit and rotating to face the same direction of the unit:

The event is every .1 seconds of game time.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • CamSetting Equal to 0
    • Then - Actions
      • -------- --------Ground Units not buildings --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Angle of attack to Camera_AoA[(Integer A)] over 0.20 seconds
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Field of view to (Camera_FieldOfView[(Integer A)] + 15.00) over 0.01 seconds
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Roll to Camera_Roll[(Integer A)] over 0.01 seconds
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Height Offset to ((Current flying height of SelectedUnit[(Integer A)]) + Camera_Height[(Integer A)]) over 0.01 seconds
          • Camera - Set (Player((Integer A)))'s camera Rotation to Camera_Rotation[(Integer A)] over 0.01 seconds
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Distance to target to 400.00 over 0.01 seconds
          • Camera - Set (Owner of SelectedUnit[(Integer A)])'s camera Far Z to Camera_FarZ[(Integer A)] over 0.01 seconds
    • Else - Actions
The first one the villager is selected - if I clicked on the area where the explosion is he would walk over there however he walk in a zig zag manner as he crossed the road. For each zig and each zag (with the rotation set to face the facing direction of the selected unit) the camera swings back and forth following his movements.

In the second, the hero would walk straight down the road (which runs "east/west" on the map this direction is facing west) - however if anything is in the road he will run around it and the camera will swing violently facing the direction he faces - rather in a sickly fashion I might add.

I've tried a delayed every 2 seconds rotation correction, but that just leaves the camera facing the wrong way and playing catch up - it does not smooth out the camera rotation movements.
 

Attachments

  • explosion.jpg
    explosion.jpg
    83.8 KB · Views: 130
  • hero.jpg
    hero.jpg
    93.2 KB · Views: 136
i dont really get your problem, but if this is what you mean, this is how i would do it.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Camera - Set (Player((Integer A)))'s camera Angle of attack to 345.56 over 0.00 seconds
          • Camera - Set (Player((Integer A)))'s camera Height Offset to 50.00 over 0.00 seconds
          • Camera - Set (Player((Integer A)))'s camera Distance to target to 400.00 over 0.00 seconds
          • Camera - Lock camera target for (Player((Integer A))) to Selectedunit, offset by (0.00, 0.00) using The unit's rotation
          • Camera - Set (Player((Integer A)))'s camera Field of view to 50.00 over 0.00 seconds
  • Sway
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Camera - Set (Player((Integer A)))'s camera Rotation to (Facing of Selecedunit) over 0.05 seconds
  • Selected Unit
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units currently selected by (Player((Integer A)))) and do (Actions)
            • Loop - Actions
              • Set Selectedunit = (Picked unit)
i hope to see your map done, did the harvest part work?
 
Last edited:
Level 8
Joined
Feb 20, 2007
Messages
338
Yes I have harvesting crops working rather well. I suspect I can clean it up a tad bit more.

Camera rotation is another thing. To understand the problem you would have to use it in a map with a few doodads. The spousal unit's comment was "this looks like a great way to make players sea-sick" while watching over my shoulder as I tested the game for the millionth time.

The Following Trigger has everything I have tried - not all at once.

  • Camera Rotation
    • Events
      • Time - Every 0.10 seconds of game time
      • Player - Player 9 (Gray) Selects a unit
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to Move To
          • (Issued order) Equal to Right-Click
          • (Issued order) Equal to Attack
          • (Issued order) Equal to Attack Ground
          • (Issued order) Equal to Attack Ground
    • Actions
      • Set Camera_Rotation[(Integer A)] = ((Facing of SelectedUnit[(Integer A)]) + 180.00)
      • Camera - Set (Player((Integer A)))'s camera Rotation to (Facing of SelectedUnit[(Integer A)]) over 0.30 seconds
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Camera - Set (Player((Integer A)))'s camera Rotation to Camera_Rotation[(Integer A)] over 0.30 seconds
All of the options are here, however I did not used them all at once. For instance all of those ordered conditions were not part of the time event.

When the event was just a selection event the camera did turn to face the direction of the selected unit - however it remained in that state until the unit was deselected and reselected.

The every .01 seconds worked however sea-sickness part of the came.

Ordering events did nothing. I tried selected unit, ordered unit, blah.

I did try using the escape key as a way to turn the camera - that worked however the player had to hit the escape key each and every single time they sent their selected unit anywhere. Although the camera did not rotate back and forth madly as the unit moved the added action on the player seems a bit too much.

I have had rotation tied into the arrow keys - because movement is available through the arrow keys, but to attack another unit or to attack the ground one uses the mouse. One can also use the mouse to move the unit through the game right clicking the ground sends the unit to that spot of ground.

Having to right click and hit the escape key to rotate the camera to face the direction of the unit seems unwieldy.

Again you really have to try having the camera rotate with the unit and follow behind the unit and then order the unit to go someplace to understand what I mean about zig-zaging, swaying, rocking, etc.
 
Status
Not open for further replies.
Top