1. The contestants were to create water structures for the 20th Terraining Contest. Choose one in the public poll!
    Dismiss Notice
  2. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  3. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  4. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Camera Rotation Around Unit upon Key Presses

Discussion in 'Triggers & Scripts' started by asdfADRiAN, Jul 31, 2010.

  1. asdfADRiAN

    asdfADRiAN

    Joined:
    Jun 8, 2010
    Messages:
    270
    Resources:
    2
    Icons:
    2
    Resources:
    2
    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
     
  2. Tirlititi

    Tirlititi

    Joined:
    Jul 11, 2010
    Messages:
    396
    Resources:
    12
    Models:
    6
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    12
    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: Jul 31, 2010
  3. asdfADRiAN

    asdfADRiAN

    Joined:
    Jun 8, 2010
    Messages:
    270
    Resources:
    2
    Icons:
    2
    Resources:
    2
    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
     
  4. Tirlititi

    Tirlititi

    Joined:
    Jul 11, 2010
    Messages:
    396
    Resources:
    12
    Models:
    6
    Maps:
    2
    Spells:
    3
    JASS:
    1
    Resources:
    12
    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.
     
  5. asdfADRiAN

    asdfADRiAN

    Joined:
    Jun 8, 2010
    Messages:
    270
    Resources:
    2
    Icons:
    2
    Resources:
    2
    Ah that worked! I had no idea it was in radians.. Thanks a bunch!

    +Rep and Credits
     
  6. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    It's in radians? I swear that you can use a unit's facing angle (which is degrees) and get the proper result from that function.
     
  7. asdfADRiAN

    asdfADRiAN

    Joined:
    Jun 8, 2010
    Messages:
    270
    Resources:
    2
    Icons:
    2
    Resources:
    2
    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.
     
  8. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    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.
     
  9. asdfADRiAN

    asdfADRiAN

    Joined:
    Jun 8, 2010
    Messages:
    270
    Resources:
    2
    Icons:
    2
    Resources:
    2
    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.
     
  10. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    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.

    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.