• 0

    posted a message on [Video] Diablo Camera & Movement

    @OneTwoSC: Go

    Lol I PM you on YouTube asking if this is possible and within a day you manage it. Nice work :P

    Have you tried this on bnet at all?

    Posted in: Tutorials
  • 0

    posted a message on [Trigger, Data] - Set camera to follow unit perfectly, no portrait 'bug'
    Quote from sgpao: Go

    First of all, very good tutorial, I've tried it, works fine. Some issues though.

    I think the position of the dialogue will not be the same for all. I play at a 1366x768 resolution. At first when I followed your setting, the camera still unlocked when I clicked on my units portrait. I realized that there must be something wrong with the button so I changed the transparency of the button back to 0% to see where it actually was. I found it in the middle of my UI, right above the unit name. I had to change the portraitFix_createDialog trigger a bit:

    Dialog - Create a Non-modal dialog of size (180, 238) at (1525, 962) relative to Top Left of screen

    I'd like to hear feedback from other people who also tried this trigger. Perhaps this might pose as a problem for people with different resolutions, the position of the button will differ for every player.

    Quote from s3rius: Go

    @sgpao: Go

    Since dialogs don't scale with screen resolution it's better to anchor the dialog_fix to the bottom right and adjust it from there. The position difference for different resolutions is much smaller then.

    Good catch. I hadn't considered that at all. I'll have to test it and change the tutorial at some point, but for the moment I'll add a note that the position may vary depending on screen resolution.

    Posted in: Tutorials
  • 0

    posted a message on [Trigger, Data] - Set camera to follow unit perfectly, no portrait 'bug'

    I couldn't find any tutorials on sc2mapster to achieve this, but I found plenty of threads of people asking how to do this and plenty of responses with half-answers and no real step-by-step. I used the information I found on sc2mapster, combined with information from OneTwoSC's 'Camera, Lighting & Cinematics' YouTube tutorial and help from Mozared and SycoPrime to come up with the following.

    This tutorial will show you how to set the game camera to precisely follow a unit without any issues such as the 'portrait breaking follow' problem. This method will not allow the camera to be moved AT ALL by the player. It will stick to the unit indefinitely. If you want to create a camera that the player can zoom, but that cannot be panned, you will need to achieve this using triggers. Such a camera is beyond the scope of this tutorial.

    With the wall of text behind us, let's get to it.

    For the purposes of this tutorial, I'm going to use a Marine as the unit I want the camera to follow.

    Part 1: Set camera to follow our unit [Trigger]

    The first thing we need to do is set up our desired camera perspective. Open the Terrain module and position the viewport to the desired perspective. I'll be positioning my camera fairly close to the unit.

    Once you have positioned your camera, press C to open the Camera layer and click Create Camera. Rename your camera to playerCam.

    Note: Delete the Melee Initialization trigger if you are using a blank map to test this tutorial.

    Open the Trigger module.

    Create a Trigger called set_playerCam.

    • Create an Event and select Map Initialization
    • Create an Action and select Camera on the left and Apply Camera Object on the right.
      • Change the action to read: Camera - Apply playerCam for player 1 over 0.0 seconds with 100% initial velocity, 0% deceleration, and Include Target
    • Create an Action and select Camera on the left and Follow Unit Group with Camera on the right.
      • Change the action to read: Camera - Follow for player 1 (Unit group(Marine [51.95, 57.23])) with the camera and Clear Current Target
        • NOTE: You set the Unit Group to your unit by selecting Convert Unit to Unit Group in the dialog box
    • Create an Action and select Camera on the left and Lock Camera Input on the right.
      • Leave the action as the default: Camera - Lock camera input for player 1

    Make sure the actions are in the right order as seen in the following screenshot. Once you are finished, close the Trigger module. We'll come back to it later.

    Part 2: Edit the camera to keep up with our unit [Data]

    We now have the camera following our unit and the player cannot move the camera manually in any way (other than by clicking the unit portrait, which we will fix in Part 3). However, the camera's default settings cause it to follow the unit slowly and smoothly. Chances are, you want the camera to follow the unit precisely instead of falling behind when the unit moves and 'chasing' it until the unit stops. This is what we'll now fix.

    Open the Data module.

    Change Data Type to Cameras.

    Select the Default Camera.

    • NOTE: You may need to modify a different camera based on the tile set of your map.

    In the fields panel on the right, enable each of the 5 view buttons at the top so you can follow which values are changed.

    Change the value of Follow Scroll Limit to 100.

    Change the value of both Scroll Acceleration Period and Scroll Deceleration Period to 0 for both Normal and Follow.

    Double-click on the value field for Target Smooth +

    • Change Displacement Minimum to 0.001
    • Change both Smooth Time Maximum and Smooth Time Minimum to 0.05
      • NOTE: If you make the values for Smooth Time Max/Min too low, the camera will be very 'jittery' when the unit moves. I recommend going no lower than 0.05 for each.
    • Change Velocity Maximum to 50000
      • NOTE: I use 50000, but anything above 100 should be sufficient

    These values all directly affect the speed at which the camera chases it's target. Lower numbers for the top 3 values and higher numbers for the bottom value will create a camera that has almost no perceptible delay in chasing a unit. The numbers I use work perfectly for me, but feel free to experiment with them to find a camera speed you are happy with.

    Also worth noting is that the camera speed should be fixed using only the modified values for Target Smooth +. However, I've seen people recommend changing Follow Scroll Limit, Scroll Acceleration Period and Scroll Deceleration Period and doing so hopefully can't hurt. It doesn't seem to cause any unwanted behaviour for me, at least.

    Part 3: Preventing a unit portrait click from breaking our camera [Trigger]

    This part of the tutorial will describe a workaround to prevent our camera from breaking when the player clicks a unit portrait.

    Open the Trigger module.

    Create a global Variable called portraitFix_dialog

    • Set Type to Dialog

    Create a global Variable called portraitFix_dialogButton

    • Set Type to Dialog Item

    Create a Trigger called portraitFix_createDialog

    • Create an Event and select Map Initialization
    • Create an Action and select Dialog on the left and Create Dialog on the right
      • Change the action to read: Dialog - Create a Non-modal dialog of size (180, 238) at (986, 962) relative to Top Left of screen
        • The size and position of the dialog box will need to be changed depending on the screen resolution you play at. The numbers given here work for 1024x768. I'll update the tutorial with co-ords for every common screen res when I get the chance to test it, but for now you'll have to play around with the numbers yourself.
    • Create an Action and select Set Variable
      • Change the action to read: Variable - Set portraitFix_dialog = (Last created dialog)
    • Create an Action and select Dialog on the left and Create Dialog Item (Button) on the right
      • Change the action to read: Dialog - Create a button for dialog portraitFix_dialog with the dimensions (180, 238) anchored to Top Left with an offset of (0, 0) setting the tooltip to "" with button text "" and the hover image set to ""
    • Create an Action and select Set Variable
      • Change the action to read: Variable - Set portraitFix_dialogButton = (Last created dialog item)
    • Create an Action and select Dialog on the left and Show/Hide Dialog on the right
      • Change the action to read: Dialog - Show portraitFix_dialog for (All players)
    • Create an Action and select Dialog on the left and Set Dialog Transparency on the right
      • Change the action to read: Dialog - Set transparency of portraitFix_dialog to 100.0

    This trigger crates a dialog box over our unit portrait, gives it a button and sets it to be invisible. When we try to click the portrait, we actually click the dialog button, which will soon be set to 'reset' our camera.

    Make sure the actions are in the correct order, as shown here.

    Create a Trigger called portraitFix_resetCam

    • Create an Event and select Dialog Item Is Used
      • Change event to read: Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
    • Create a Condition and select Comparison
      • Change compare by clicking the bracket at the start of the condition, selecting Dialog on the left and Used Dialog Item on the right
      • Set Value 2 to portraitFix_dialogButton
    • Go back to your set_playerCam trigger and copy the following actions
      • Camera - Follow for player 1 (Unit group(Marine [51.95, 57.23])) with the camera and Clear Current Target
      • Camera - Lock camera input for player 1
    • Paste those two actions into the Actions for your portraitFix_resetCam trigger

    This trigger sets up what happens when we click the dialog button while trying to click the portrait. We set the to follow our unit again here to ensure that our camera will not break.

    Make sure the actions are in the correct order, as shown here.

    Done!

    Your camera should now be locked permanently to your unit and shouldn't be moveable.

    Notes & Known Issues

    • As far as I know, the camera will target the base of the unit (the centre point of it's selection circle). You can add an action in the set_playerCam trigger, before the other actions, to add a height offset to make the camera targets the mid-point of the unit's height.
      • Camera - Set set_playerCam Height Offset to 0.5
        • NOTE: Set a higher or lower value based on the size of your unit
    • Clicking the portrait will produce a button click sound that I haven't yet figured out how to get remove.
    • The size and position of the dialog covering the unit portrait is not pixel-perfect and could be tweaked further.
    • The numbers given for the dialog covering the unit portrait works for resolutions of 1024x768. You'll need to try different numbers to get the dialog in the right place, depending on your screen resolution.

    Thank you to Mozared, SycoPrime and OneTwo for their help.

    If anyone has any problems with this tutorial, has any suggestions to improve it or sees any typos and spelling mistakes, please leave a reply and I'll get back to you as soon as I can.

    Posted in: Tutorials
  • To post a comment, please or register a new account.