It works like you say it does. If not for wanting it to deselect the unit with a left click, you could have just added an into the left click trigger to select the unit at that point for the current player.
I found a few things frustrating with it - you can't click and drag and if you have your unit selected and then left click to rotate the camera, it deselects the unit. I guess its not an issue if you are using a different control system though.
- #1
Huesy AuthorContents
Edit
cecilofs' post below made a good point that the unit is deselected whenever you want to look with the camera. I've attached v2 of the solution below. Once "Lock Camera Mouse Relative Mode" is called, the unit is technically no longer highlighted because the cursor is automatically hidden.
The new solution makes use of the original, but now the unit is stored in another variable when the mouse is down. And when the mouse is released (Up), the "Highlight On" trigger will be called if a unit is highlighted. The new version checks that the mouse up highlighted unit is the same one as when the mouse was pressed down and highlights it if so!
Triggers
Mouse Down
Highlight Off
Original Post
Some of you may have played around with camera movement using the mouse. i.e. You click your mouse button and drag to move the camera around a point on the map. But there's one problem when using this technique: You can't click on anything to select it! This is a major problem for those wanting to be able to click as well as move the camera.
Following is a basic tutorial on my solution for this problem which works quite well. It also lets you de-select a unit by clicking on an empty space.
Here we go:
First we'll set up the camera. This will also allow you to see why the workaround is needed.
The Problem
The Solution
The solution makes use of the in-built event that is triggered when you hover your mouse over a unit.
Now test your map and you can see that you can not only move the camera with your mouse, but you may also click the unit and click off it to deselect! This should be very useful for those of you working on RPG type maps with a movable camera.
Unit Placement
Mouse Triggers
Mouse Down 01
Mouse Up
Highlighting Triggers
Highlight On
Highlight Off
Mouse Down 02
Data Editor
Mouse Down v2
Highlight Off v2
Triggers v2