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

Camera Rotation Around Unit upon Key Presses

Status
Not open for further replies.
Level 7
Joined
Jun 8, 2010
Messages
283
So basically im trying to achieve is rotating the camera 360 degrees around a unit. To be clear, I dont mean it will rotate aorund a unit a FULL 360 for a Left Press and a -360 for a Right press, but bit by bit.

I want the camera to rotate x degrees when a player presses a key.

I have two triggers, one that sets the variable (left, right,down,up) to true when the corresponding keys are pressed.

Following that this trigger will fire:
  • Set Camera 2
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurrentCamera[(Player number of (Picked player))] Equal to 2
              • Right[(Player number of (Triggering player))] Equal to True
            • Then - Actions
              • Camera - Set (Triggering player)'s camera Rotation to -1.00 over 1.00 seconds
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurrentCamera[(Player number of (Picked player))] Equal to 2
              • Left[(Player number of (Triggering player))] Equal to True
            • Then - Actions
              • Camera - Set (Triggering player)'s camera Rotation to 1.00 over 1.00 seconds
            • Else - Actions
 
You didn't speak about your problem. Doesn't it work? How it bugs if so?

At first look, you have 2 problems :
1) You sometimes use "Triggering player" instead of "Picked Player'".
2) You rotate the camera too slowly (over 1 second) and don't use the previous value. You should use that :
  • Camera - Set (Picked player)'s camera Rotation to (rotation of the current camera view + 1.00) over 0.00 seconds
Also, there is a bug by using "Change the camera bounds", you shouldn't use this action anywhere in your map cause it triggers a fatal error if your camera rotation is about 270 degrees oriented.
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Sorry.

Well my camera does nothing. Its just locked onto the unit (through another trigger) but thats the problem. My problem is that the camera doesnt rotate around the unit when Left or Right arrow keys are pressed. The camera pretty much will just "Reset".

I re-did the trigger a bit and changed the minor mistakes to "Picked Player" as well as tried to modify the camera. But all the camera does when Left or Right is pushed is just "apply" the default game camera, where once again my West, North, South, and East are all in coordinate directions in aspect to the camera.
  • Set Camera 2
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurrentCamera[(Player number of (Picked player))] Equal to 2
              • Right[(Player number of (Picked player))] Equal to True
            • Then - Actions
              • Camera - Set (Picked player)'s camera Rotation to ((Rotation of the current camera view) - 1.00) over 0.00 seconds
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurrentCamera[(Player number of (Picked player))] Equal to 2
              • Right[(Player number of (Picked player))] Equal to True
            • Then - Actions
              • Camera - Set (Picked player)'s camera Rotation to ((Rotation of the current camera view) + 1.00) over 0.00 seconds
            • Else - Actions
 
Ho, I forgot that the camera's rotation are returned in radians senselessly, not in degrees.
So you have to do something like that :

  • Camera - Set (Picked player)'s camera Rotation to (((Rotation of the current camera view) x (180.00 / Pi)) - 1.00) over 0.00 seconds
I also see that you use twice the boolean "Right", I guess you should have put "Left" instead of one of these.

If it doesn't work with that, then your problem is in the "Press/Release key" triggers.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Well you see Berb, all the tutorials here are only based on the units degree angle meaning, you HAVE to rotate the unit as well. That isnt what I was going for.

I know how to make a camera rotate prior to a unit's rotation, but my system has 3 cameras. One locked onto the unit using the unit's facing degree rotation, and one where a unit can manually move the camera around regardless of unit's facing angel and another that is an aerial view (eagle view).

If i wanted radius, then yes I would of went with unit rotation, but everyone knew how to do that, thanks to tutorials. Camera tutorials however only were 1st or 3rd person, which made the absolutely useless when it came to other cameras.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I'm not going based on tutorials, I'm going based on personal experience. I've worked a lot with cameras.

I see now what was wrong. The function that obtains the camera's current rotation returns a value in radians, while the function that sets the camera's rotation takes a degree parameter. I remember finding this out before when I was doing some of my "intuitive" camera system.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Thats not what I was saying. What I meant about thet tutorials is that they primariyl set the basic knowledge of the average user. Because these tutorials were all based upon the unit's facing rotation rather than the camera itself, it made it seem more difficult.

Also the set function will reset the camera when finished, back to the default position. Just noting this for future archiving.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I don't know why you're bringing up tutorials; I only asked a simple question. I see why you were having troubles, but that isn't what I was asking.

Also the set function will reset the camera when finished, back to the default position. Just noting this for future archiving.

No it won't. The camera will be able to be reset via the user scrolling his mouse wheel but that really isn't something specific to the "set" function. That is just user input changing the fields of the camera, instead of triggers - this is "hard coded" by Blizzard.
 
Status
Not open for further replies.
Top