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

Third person camera system

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi there.

I have almost completed the third person view camera system for my proyect, but thera is still one thing I can't fix.
Let's see, I'll begin posting all the triggers of the system (they are 14):

NOTE: Before each of the triggers, I put ON or OFF. That indicates if the trigger is initially ON or initially OFF.

ON
  • Camera variables
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Set Camera_View = (Rotation of Current Camera)
      • Set Camera_Height = (Angle of attack of Current Camera)
ON
  • Hero's position
    • Events
      • Events - every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Hero_Position = (Position of Hero)
      • Custom script: set udg_Hero_Z = GetLocationZ(udg_Hero_Position)
ON
  • Camera Settings
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • CAMERA_CONTROL Equal to True
    • Actions
      • Camera - Set Player 1 (red)'s camera Distance to 1000.00 over 0.50 seconds
      • Camera - Set Player 1 (red)'s camera Field of View to 100.00 over 0.50 seconds
      • Camera - Set Player 1 (red)'s camera Z height to Hero_Z over 0.50 seconds
      • Camera - Set Player 1 (red)'s camera Far Clipping to 100000.00 over 0.50 seconds
ON
  • Move left ON
    • Events
      • Player - Player 1 (red) Presses the Left arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn on Move left
ON
  • Move left OFF
    • Events
      • Player - Player 1 (red) Releases the Left arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn off Move left
OFF
  • Move left
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Camera - Set Player 1 (red)'s camera Rotation to (Camera_View + 8.00) over 0.10 seconds
ON
  • Move right ON
    • Events
      • Player - Player 1 (red) Presses the Right arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn on Move right
ON
  • Move right OFF
    • Events
      • Player - Player 1 (red) Releases the Right arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn off Move right
OFF
  • Move right
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Camera - Set Player 1 (red)'s camera Rotation to (Camera_View - 8.00) over 0.10 seconds
Camera_View is a real variable.
Camera_Height is a real variable.
Hero_position is a point variable.
Hero_Z is a real variable.
CAMERA_CONTROL is a boolean variable. It's always true. It only gets false during cinematics, for obvious reasons.

Now, until here, the system works fine. The camera folows the Hero, and the player can rotate the camera around with the arrow keys. It doen't lag at all, it's all nice and good.
OK, now I tried to let the player move the camera up and down with the other two arrow keys (Up and Down). However, I can't let the player do this infinitely. The maximum angle of attack should be 350.00, and the minimum should be 310.00. fine, THAT is what I'm not able to do.
Here are the rest of the triggers:

ON
  • Move up ON
    • Events
      • Player - Player 1 (red) Presses the Up arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn on Move up
ON
  • Move up OFF
    • Events
      • Player - Player 1 (red) Releases the Up arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn off Move up
OFF
  • Move up
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Camera - Set Player 1 (red)'s camera Angle of attack to (Camera_Height + 5.00) over 0.10 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else actions)
        • If: Conditions
          • (Angle of attack of the current camera view) Higher or equal than 350.00
        • Then: Actions
          • Camera - Set Player 1 (red)'s camera Angle of attack to 350.00 over 0.10 seconds
          • Trigger - Run Move up OFF <gen> (checking conditions)
        • Else: Actions
          • Do nothing
ON
  • Move down ON
    • Events
      • Player - Player 1 (red) Presses the Down arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn on Move down
ON
  • Move down OFF
    • Events
      • Player - Player 1 (red) Releases the Down arrow key
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Trigger - Turn off Move down
OFF
  • Move down
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • CAMERA_CONTROL is Equal to True
    • Actions
      • Camera - Set Player 1 (red)'s camera Angle of attack to (Camera_Height - 5.00) over 0.10 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else actions)
        • If: Conditions
          • (Angle of attack of the current camera view) Lesser or equal than 310.00
        • Then: Actions
          • Camera - Set Player 1 (red)'s camera Angle of attack to 310.00 over 0.10 seconds
          • Trigger - Run Move down OFF <gen> (checking conditions)
        • Else: Actions
          • Do nothing
That's it. It doesn't work. When I press the Down arrow key, the camera goes straight to the 310.00 angle of attack position, no matter what it currently has. When I press the Up arrow key, the camera's angle of attack just keeps increasing indefinitely.
I know that this may not be the best and most efficient way to make this camera system, but that's how I tried to do it. And now, I want to know what's wrong with it. I gave you all the triggers of the system, and I told you what's the error, so I hope you could help me find the problem.

Thanks in advance, and sorry for the long post.

Regards
 

Deleted member 177737

D

Deleted member 177737

I think this is what you are trying to make...



Keyboard[] is a interger array.
  • Initilization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Camera - Lock camera target for Player 1 (Red) to Player_Hero, offset by (0.00, 0.00) using Default rotation
      • -------- Destroy trigger since it only runs once, --------
      • Custom script: call DestroyTrigger (GetTriggeringTrigger())
  • Camera Left Press
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set Keyboard[1] = True
      • Trigger - Turn on Camera Rotate <gen>
  • Camera Left Release
    • Events
      • Player - Player 1 (Red) Releases the Left Arrow key
    • Conditions
    • Actions
      • Set Keyboard[1] = False
      • Trigger - Turn off Camera Rotate <gen>
  • Camera Right Press
    • Events
      • Player - Player 1 (Red) Presses the Right Arrow key
    • Conditions
    • Actions
      • Set Keyboard[2] = True
      • Trigger - Turn on Camera Rotate <gen>
  • Camera Right Release
    • Events
      • Player - Player 1 (Red) Releases the Right Arrow key
    • Conditions
    • Actions
      • Set Keyboard[2] = False
      • Trigger - Turn off Camera Rotate <gen>
  • Camera Up Press
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Camera - Set Player 1 (Red)'s camera Angle of attack to 304.00 over 1.00 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to 1650.00 over 1.00 seconds
  • Camera Down Press
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Camera - Set Player 1 (Red)'s camera Angle of attack to 335.00 over 1.00 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to 1200.00 over 1.00 seconds
The next trigger needs to be set to INITALLY OFF

  • Camera Rotate
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • -------- Turn Camera Left --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Keyboard[1] Equal to True
        • Then - Actions
          • Camera - Set Player 1 (Red)'s camera Rotation to ((Rotation of (Current camera)) - 3.00) over 0.15 seconds
        • Else - Actions
          • -------- Turn Camera Right --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Keyboard[2] Equal to True
            • Then - Actions
              • Camera - Set Player 1 (Red)'s camera Rotation to ((Rotation of (Current camera)) + 3.00) over 0.15 seconds
            • Else - Actions
 
Level 9
Joined
Apr 19, 2011
Messages
447
Yayoi, your system is not what I'm trying to make... In your system, when you press the up arrow key, the camera goes up to the minimum angle of attack, and when you press the down arrow key, goes down to the maximum angle of attack... but there's no middle point, the player can't adjust the angle of attack as he wants.

I want the camera to go up or down ONLY while the keys are pressed, and to stop when they are released. I want the camera to go up or down gradually, and to be stoppable at any time. But, it has to be a limit. The angle of attack mustn't be lower than 310 of higher than 350.
That's what I'm trying to make.


In other words... Yayoi, I want to do with the angle of attack the SAME thing you did with the rotation, but inside of certain limits, as I said before.

Regards
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
you camera is like this for example;

Move Down
  • Camera - Set Player 1 (red)'s camera Angle of attack to (Camera_Height - 5.00) over 0.10 seconds
the Camera_Height is at constant value subtracted only by 5 coz your angle is only "(Angle of attack of Current Camera)", so if your angle is only '310', the result is always 310-5 = 305 or 310+5 = 315 (MoveUp)...

so you need to really reduce it by;
  • Untitled Trigger 002
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Trigger - Turn on CamH <gen>
  • Untitled Trigger 002 Copy
    • Events
      • Player - Player 1 (Red) Releases the Down Arrow key
    • Conditions
    • Actions
      • Trigger - Turn off CamH <gen>
  • CamH
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Camera_Height = (Camera_Height + 5.00)
      • Camera - Set Player 1 (Red)'s camera Angle of attack to Camera_Height over 0.10 seconds
this is only an idea of what I mean...
 
Level 9
Joined
Apr 19, 2011
Messages
447
you camera is like this for example;

Move Down
  • Camera - Set Player 1 (red)'s camera Angle of attack to (Camera_Height - 5.00) over 0.10 seconds
the Camera_Height is at constant value subtracted only by 5 coz your angle is only "(Angle of attack of Current Camera)", so if your angle is only '310', the result is always 310-5 = 305 or 310+5 = 315 (MoveUp)...

so you need to really reduce it by;
  • Untitled Trigger 002
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Trigger - Turn on CamH <gen>
  • Untitled Trigger 002 Copy
    • Events
      • Player - Player 1 (Red) Releases the Down Arrow key
    • Conditions
    • Actions
      • Trigger - Turn off CamH <gen>
  • CamH
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Camera_Height = (Camera_Height + 5.00)
      • Camera - Set Player 1 (Red)'s camera Angle of attack to Camera_Height over 0.10 seconds
this is only an idea of what I mean...

Thanks! I already saw my mistake. It works fine now!
That's it then, problem solved.

Regards
 
Status
Not open for further replies.
Top