1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Third Person Camera/Movement

Discussion in 'StarCraft II Modding' started by Lee_Go, Aug 19, 2010.

  1. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Hi, I'm trying to make a specific unit move with the arrow keys, or WASD.
    W is forward, S backwards, A turns the unit left, D turns the unit right.
    Only difference is the camera. I don't want it FPS camera, i want a camera that is set and turns as the unit turns, as to keep it looking in the direction you are facing.

    If someone could link or explain the triggering... thank you. +Rep
     
  2. LazyCoder

    LazyCoder

    Joined:
    Aug 2, 2006
    Messages:
    345
    Resources:
    0
    Resources:
    0
    I think you mean A and D strafe, not turn. Even if you DID mean turn, I'd highly recommend against that. Those controls ruined "Alone in the Dark" for me.

    Basically, what you should do is make a blank unit in the data editor with no model, but it can move, and this is what you use as the unit with the "follow unit group" action with the camera.

    You need to have two triggers for each key, one detecting when the key goes down, another when it is released. Have a boolean variable for each key that corresponds to it's current state (so if the key is down, it's "true", if it's up, it's "false").

    Then you'll have a trigger for your main movement loop. Event for this trigger should be "every 0.3125 real time seconds". Use a bunch of if-then-else statements for each key to see if it's pressed. I used 8 because you're not just moving up/back, left/right, you can also move diagonally by holding two down. The way I dealt with that was I just had it check every key (ie. "if up true, down false, left false, right false" then move forward.)

    Inside each "if" statement, you'll want to make the unit move relative to the camera's facing, NOT THE UNIT'S facing. I'm pretty sure there's a function in there, like point with offset, or something like that.
     
  3. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Uhm for what i'm trying to do, since it's fixed camera.... No, I would not want it to strafe. A goes left, D goes right. Because the camera follows where the unit is looking. For what i'm trying to do it doesn't need to be easy and fluent to move like you would think, not trying to be manuverable or anything, turning right and left works fine.
     
  4. gaby-boy

    gaby-boy

    Joined:
    Jun 14, 2009
    Messages:
    114
    Resources:
    5
    Spells:
    4
    Tutorials:
    1
    Resources:
    5