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.
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.
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.
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.
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.
Can't you have a trigger "On mouse left click, wait 0.1 game seconds, and reset the camera" It skips the entire dialog button problem. The only issue is it will reset the camera with every click and if too many trigger commands slow down your game speed, then this extra trigger every mouse click will contribute to the trigger calculation load. At least then you don't have to deal with the resolution screwing up the location of the button
Why do all tutorials assume the unit is already on the map? I think this is a great tutorial but I can never figure out how to use any tutorial for a unit not already made. At the beginning of the map the players spawn at a random point in the base. After they die they respawn after 5 seconds in their base at a random spawn point. I can get the spawn but not the camera to work. I set the camera up near the middle and it just stays there. How do I tell it to go to the last created unit? Saying last created unit doesn't seem to work.
You could pick a unit with the trigger isntead of having one specific on your map.
I use the trigger below. It picks players from a player group (activePlayers in my case) and runs the actions for each. This works as long as you have only one unit owned per player at any given time. It works for one player at least (I havnt tested online) and I'm not sure that several players can share a camera object.
For the portrait bug, you can see I use the solution Draken2223 suggested in the thread stevehammon reffered to a couple of posts above. I hope the repeat actions forever-part wont slow the game online.
Otherwise, the camera will attempt to follow both units. You actually use the same trigger fro start/stop followiong. There was a lot of frustration before I foudn that out :)
Please let me know if you try this online. Can several players share a camera object?
If you don't want the button sound, don't use a button. And instead of using the transparency just use the "black" image as background. If you use an image to cover up the portrait and then set a tooltip for that image (hero's name or something) it will prevent the protrait to be clicked as well. By the way, everything in your UI will block clicking if it has a tooltip...
Is it possible to disable the portrait part of the interface, or is the command card, portrait, etc one huge UI element?
BTW, the answer to the question in my last post seems to be yes - at least two players over bnet can share the same camera object with the trigger I made. I don't know if they get one instance of the object each, or if the camera is taking turns (every 0.1 second) to display for both players. Either way, the visual result is the same.
I attached the same region to two player units in a similar fashion, but not every 0.1 second as in the trigger above - which leads me to believe that my first guess is correct (an instance of an object is created for both players, at least cameras that follows and attached regions).
I did follow this exactly, but I still have one problem. Basically the camera doesn't go behind the unit, more on top of it. If anyone knows why this is please reply ASAP.
I tried parts one and two of this tutorial, then tested the map to better understand the 'portrait bug'. I had no issues at all, without trying the fix mentioned in the original post or the one linked by stevehammon. Not sure why. I'm a complete noob.
I understand the original post is old, so mainly just posting for others that may stumble upon it.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
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.
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.
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 +
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
Create a global Variable called portraitFix_dialogButton
Create a Trigger called portraitFix_createDialog
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
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
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.
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:
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.
<3 rock on brother
@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.
In my map the player picks from 1 of 4 units there is no unit on the map to select from the start how can i work around this?
Can't you have a trigger "On mouse left click, wait 0.1 game seconds, and reset the camera" It skips the entire dialog button problem. The only issue is it will reset the camera with every click and if too many trigger commands slow down your game speed, then this extra trigger every mouse click will contribute to the trigger calculation load. At least then you don't have to deal with the resolution screwing up the location of the button
http://forums.sc2mapster.com/development/map-development/11302-camera-object-rotation/#p13
There is your fix. Simple and Elegant
Why do all tutorials assume the unit is already on the map? I think this is a great tutorial but I can never figure out how to use any tutorial for a unit not already made. At the beginning of the map the players spawn at a random point in the base. After they die they respawn after 5 seconds in their base at a random spawn point. I can get the spawn but not the camera to work. I set the camera up near the middle and it just stays there. How do I tell it to go to the last created unit? Saying last created unit doesn't seem to work.
You could pick a unit with the trigger isntead of having one specific on your map.
I use the trigger below. It picks players from a player group (activePlayers in my case) and runs the actions for each. This works as long as you have only one unit owned per player at any given time. It works for one player at least (I havnt tested online) and I'm not sure that several players can share a camera object.
For the portrait bug, you can see I use the solution Draken2223 suggested in the thread stevehammon reffered to a couple of posts above. I hope the repeat actions forever-part wont slow the game online.
If you want to switch to another unit or point to view you need to use this action first:
Otherwise, the camera will attempt to follow both units. You actually use the same trigger fro start/stop followiong. There was a lot of frustration before I foudn that out :)
Please let me know if you try this online. Can several players share a camera object?
If you don't want the button sound, don't use a button. And instead of using the transparency just use the "black" image as background. If you use an image to cover up the portrait and then set a tooltip for that image (hero's name or something) it will prevent the protrait to be clicked as well. By the way, everything in your UI will block clicking if it has a tooltip...
Is it possible to disable the portrait part of the interface, or is the command card, portrait, etc one huge UI element?
BTW, the answer to the question in my last post seems to be yes - at least two players over bnet can share the same camera object with the trigger I made. I don't know if they get one instance of the object each, or if the camera is taking turns (every 0.1 second) to display for both players. Either way, the visual result is the same. I attached the same region to two player units in a similar fashion, but not every 0.1 second as in the trigger above - which leads me to believe that my first guess is correct (an instance of an object is created for both players, at least cameras that follows and attached regions).
I did follow this exactly, but I still have one problem. Basically the camera doesn't go behind the unit, more on top of it. If anyone knows why this is please reply ASAP.
@Donutduffer: Go
make your own camera and edit it. then link the triggers to your camera. pretty easy
( when you open up the camera settings , you can check the box ( game view or w*/e) and it allows you to see what you would see in game.
you will need a camera for EACH players doh.
@MillsySC: Go
I tried parts one and two of this tutorial, then tested the map to better understand the 'portrait bug'. I had no issues at all, without trying the fix mentioned in the original post or the one linked by stevehammon. Not sure why. I'm a complete noob.
I understand the original post is old, so mainly just posting for others that may stumble upon it.