It seems that is only way to get mouse X and Y is from the last 'clicked' location. So you cannot really fire a machine gun without getting tendinitis. I seen some youtubes of the mouse moving the camera and then shots are fired where the camera is facing, but I am making a top down shooter so that won't work for me. Anyone have any ideas?
While I suppose this works for a top-down shooter, I need to access the mouse's actual position (or relative movements). What I plan to do is have a ship turn clockwise when the mouse turns right and vice-versa, while keeping the camera centered on the ship. Is there any way to do this?
Unfortunately, as has been established, there is no way to track mouse movement by itself without having the player trigger a Click event. The ONLY method of tracking mouse movement without relying on said events is to tie it's relevant movement to the position of the camera. This does however mean that you cannot lock your camera onto a unit.
There are three cool events along the lines of what you need,
Unit Clicked (when you click a unit with the Unit Flag 'Cannot Be Clicked' disabled)
Unit Selected/Deselected (when you click/click off a unit that can be selected)
Unit Highlighted/Un-Highlighted (The way it works is that when your mouse moves over or off a units model with Unit Flag 'Cannot Be Highlighted' disabled and the model flag the event fires) This is for your machine gun. when ya left click is down boolean is true. If this even fires (and the clicking boolean is true) start a machine gun attack on the unit. When either the un-Hilighted event fires (with triger unit= the initial triger unitt) OR the clicking boolean is false remove the machine gun attack.
(Also important, for this to work on a unit its actor must have Model Flags->Allow Hit Test ticked)
In order to test Highlighted/Un-Highlighte have a Event when unit highlighted print a debug and place a few 'Cube' units on the map (they have the actor flag disabled by default). (Or if you are feeling violent just take the 'trigger unit' and kill it when the event fires!)
I dont have a good way for you to test where your mouse is when its over the ground (rather than a unit with these flags enabled) but I do have a few potential BAD ways (I mean REALY bad!!! terrible practise, should be shot for doing it kind of bad!).
The first (and by FAR the worst!!!) method is to grid out your map in tiny low height cube units, this will give you the quadrant that your mouse is currently in in combination witht he hilightable method above... (its rely very bad I know)
Alternatly i am currently working on an alternative that involves getting a handle on the actor splat (cursor pic actor generat at/following your mouse cursor when you click to use a move like EMP or nuke... Works going well but with uni it could be a week or 2 before I can finsh this and post what to do.
P.S. Using highlight as a selection method rather than a trace line has the advantage that the unit is only selected if your mouse is over the model, (CURVES!). rather than simply asking is my screen centre intersecting with a cylinder strapped to the centre of this unit (circle region combined with height restrictions)
However it has the disadvantage that in order to check whether a unit is flagged for ‘highlight’ you MUST have the mouse cursor active (no mouse rotation/lock screen mouse relative) stuff.
As a side note, as always there is an exception to the rule... When using a sniper rifle in FPS mode there is a sufficent excuse/allowance for a UI pause when shooting to allow a nifty hack solution to regaining your cursor (for a tiny period of time) and forcing the cursor to the centre of your crosshair.
You must lock the screen, go to non mouse relitive mode, set the field of view to something TINY (.0001), wait for a period of time/until highlighted event fires, and revert to normal FPS viewing conditions... Its acceptable for stationary precision shooting (as it allows model tested shooting rather than cylinder tested shooting!!!) but not for fast paced action as a assault rifle that locked up the screen for .1-.2 seconds every bullet... well thats just not 'spray and pray' now is it...
I'm kind of wondering if a dummy camera could capture the mouse look for you. Say you want player 1's look- you'd have a camera follow system set up in first person mode from the first unused player. Say: player 5 follows player 1 etc.
Nvm. You'd still need values to rotate his camera with.
I'm hoping maybe with some1's custom script perhaps mouse position X,Y as Real.
A dummy system doesn't work since you can only make a player's camera follow his own mouse movements. You can't make player 5's camera follow player 1's mouse.
If that did work it would've been quite awesome.
But alas..
So its impossible to make unit face direction of mouse pointer ?
Maybe its possible with creating some kind of dummy caster that would cast spell every (less than second) at the position of mouse pointer[force playr to click(but does nothing)-use spell] then forcing another unit to face that direction ?
There are ways to do this using CameraForceMouseRelative and CameraSetMouseRotates, but there are unfortunate side effects: the camera moves :( It is clearly within Blizzard's capacity to have a way to directly get the mouse location, and the fact that they have not done so is just pathetic.
The best method I have found so far is to use CameraForceMouseRelative and a very small mouse sensitivity so that the camera does not move much. Every frame (1/16th of a second) I move the camera back to where it should be, and use the difference between where the camera is and where it should be to calculate how much the mouse has moved.
It seems that is only way to get mouse X and Y is from the last 'clicked' location. So you cannot really fire a machine gun without getting tendinitis. I seen some youtubes of the mouse moving the camera and then shots are fired where the camera is facing, but I am making a top down shooter so that won't work for me. Anyone have any ideas?
@therockman: Go
Since it's a top down locking mouse relative mode will work just fine for you.
While I suppose this works for a top-down shooter, I need to access the mouse's actual position (or relative movements). What I plan to do is have a ship turn clockwise when the mouse turns right and vice-versa, while keeping the camera centered on the ship. Is there any way to do this?
@XPilot: Go
Unfortunately, as has been established, there is no way to track mouse movement by itself without having the player trigger a Click event. The ONLY method of tracking mouse movement without relying on said events is to tie it's relevant movement to the position of the camera. This does however mean that you cannot lock your camera onto a unit.
@therockman: Go
There are three cool events along the lines of what you need,
(Also important, for this to work on a unit its actor must have Model Flags->Allow Hit Test ticked)
In order to test Highlighted/Un-Highlighte have a Event when unit highlighted print a debug and place a few 'Cube' units on the map (they have the actor flag disabled by default). (Or if you are feeling violent just take the 'trigger unit' and kill it when the event fires!)
I dont have a good way for you to test where your mouse is when its over the ground (rather than a unit with these flags enabled) but I do have a few potential BAD ways (I mean REALY bad!!! terrible practise, should be shot for doing it kind of bad!).
The first (and by FAR the worst!!!) method is to grid out your map in tiny low height cube units, this will give you the quadrant that your mouse is currently in in combination witht he hilightable method above... (its rely very bad I know)
Alternatly i am currently working on an alternative that involves getting a handle on the actor splat (cursor pic actor generat at/following your mouse cursor when you click to use a move like EMP or nuke... Works going well but with uni it could be a week or 2 before I can finsh this and post what to do.
P.S. Using highlight as a selection method rather than a trace line has the advantage that the unit is only selected if your mouse is over the model, (CURVES!). rather than simply asking is my screen centre intersecting with a cylinder strapped to the centre of this unit (circle region combined with height restrictions)
However it has the disadvantage that in order to check whether a unit is flagged for ‘highlight’ you MUST have the mouse cursor active (no mouse rotation/lock screen mouse relative) stuff.
As a side note, as always there is an exception to the rule... When using a sniper rifle in FPS mode there is a sufficent excuse/allowance for a UI pause when shooting to allow a nifty hack solution to regaining your cursor (for a tiny period of time) and forcing the cursor to the centre of your crosshair. You must lock the screen, go to non mouse relitive mode, set the field of view to something TINY (.0001), wait for a period of time/until highlighted event fires, and revert to normal FPS viewing conditions... Its acceptable for stationary precision shooting (as it allows model tested shooting rather than cylinder tested shooting!!!) but not for fast paced action as a assault rifle that locked up the screen for .1-.2 seconds every bullet... well thats just not 'spray and pray' now is it...
I kinda need this also. Even wc3 was able to follow mouse... Tho, there wasnt mouse hold detection. I hear that here it is.
I'm kind of wondering if a dummy camera could capture the mouse look for you. Say you want player 1's look- you'd have a camera follow system set up in first person mode from the first unused player. Say: player 5 follows player 1 etc.
Nvm. You'd still need values to rotate his camera with.
I'm hoping maybe with some1's custom script perhaps mouse position X,Y as Real.
@MiketheSspike: Go
A dummy system doesn't work since you can only make a player's camera follow his own mouse movements. You can't make player 5's camera follow player 1's mouse. If that did work it would've been quite awesome. But alas..
The Dominion needs your help: http://us.starcraft2.com/dominion/
Anyone else find a solution for the top down?
How does waterworks work ? It has mouse traceline. I mean you can pick direction where you want to shoot ? Or its aligned to the center of screen ?
@tigerija: Go
It's calculating the trance line from the screen angle, yaw and pitch.
Ill post a top down sample in a few days, though the only way (I know of) to do it is fairly rugged...
I suspect that blizzard will put in a function to query the mouse cursor position of a player eventually... anyhow, watch this space.
So its impossible to make unit face direction of mouse pointer ?
Maybe its possible with creating some kind of dummy caster that would cast spell every (less than second) at the position of mouse pointer[force playr to click(but does nothing)-use spell] then forcing another unit to face that direction ?
There are ways to do this using CameraForceMouseRelative and CameraSetMouseRotates, but there are unfortunate side effects: the camera moves :( It is clearly within Blizzard's capacity to have a way to directly get the mouse location, and the fact that they have not done so is just pathetic.
The best method I have found so far is to use CameraForceMouseRelative and a very small mouse sensitivity so that the camera does not move much. Every frame (1/16th of a second) I move the camera back to where it should be, and use the difference between where the camera is and where it should be to calculate how much the mouse has moved.