ok i tried to create shooting system for 3ps using cursor position as point, but i met a problem, i can't target AIR at all, if i target ground everything just goes fine, but when i target anything else, missiles are going to random position, is there way to fix it?

UntitledTrigger002EventsUI-PlayerAnyPlayerclicksAnymousebuttonDown.LocalVariablesCURSORCLICKPOSITION=(Point((MouseXpositionclickedintheworld),(MouseYpositionclickedintheworld)))<Point>ConditionsActionsPlayerGroup-PickeachplayerinACTIVEPLAYERSanddo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfMOUSELOOKING[(Pickedplayer)] == True
(Triggering player) == (Picked player)
Then
Unit - Order CHARACTER[(Pickedplayer)] to ((ABILITY) (BUTTON) Shock Cannon targeting CURSOR CLICK POSITION) (Replace Existing Orders)
Else

your screen is 2D, how do you click at a 3D position?

add a text output with the values of x y and z and you will see what is wrong.

ok what "Mouse Z position clicked in the world" is for then? =) and why when i target skies missiles is actually going top? i don't understand hows this working at all. Is there way to get this done somehow?

yes, do some test!
use triggers to print the value of X - Y - Z position of the mouse each time. you will then see what's wrong, then we might talk about why and how to solve it.

Rollback Post to RevisionRollBack

i deleted my old skype, contact me for new one. I am for hire now! My Legacy - All of my maps as open source

Let me share you my experience and maybe a second look at the implementation: I started doing a 3PS a while back for the heck of it and learned a few things (still have the file somewhere):

Tracelines are a nono, except for range finding, when you just want to know if and where the 3d line intercepts the ground (thats the max range of your search area)

Check for angles, far better and faster to find than exact positions.

Adding visual debug tools (something as simple as teleporting a small collision-less orb to the point where you think you're aiming every second or so) can be really powerful tools to find out what the hell your algorithm is doing.

The way i did it (and worked wonderfully for me) was to compare the angle of attack and rotation of my camera, to the angle of attack and angle difference of each unit in the unit group comprising of all the units at most traceline distance of my unit.

That is:

Initial Angle:

Before anything fancy you should prepare your data, if you're gonna make the weapons spread then get the camera rotation and angle of attack and randomize them for the spread effect, then pass these new angles for the next steps.

Traceline:

Repeat X number of times or until your distance is = to the maximum distance (32 is good enough), where X*Step is enough to cover your max range

Check at the current point if Sin(angle of attack) is higher or lower than the ground height

It isn't? then add Step to the Distance and recalculate the next current point. Step can be set proportional to the distance, the further we go, the fewer checks we can make, to cover more distance with the same amount of checks, or the same distance with fewer checks. In my opinion never go beyond 50 checks per traceline.

It is? then that distance is your new maximum range.

Find Group:

Get all the units belonging to the enemy or neutral with filters blah blah blah within at most the maximum range

Get the angle difference of each unit, is it bigger than [maximum spread of gun]?

It is: remove that fucker because he ain't getting shot with this bullet

It isn't: this mofo may get the lucky strike

Refine Search:

So we have all the units in front of the player that may get shot, time for the hard math.

Lets asume for simplicity that all units have a sphere as its collision polygon (funny fact, they usually have 1 or 2), this means that any point between its center and its radius will collide with it

If we get the Absolute Value of the subtraction of both, the facing angle of our traceline and the angle between our unit and the current unit and we compare it to the radius of our current unit:

If its bigger: our projectile is too far from the collision sphere. Remove that unit form the group and move on

Its equal or smaller: our projectile intercept the collision sphere on the horizontal axis. We need more Dataz

If we then compare the Absolute of the subtraction between the Angle of attack and the Angle of Elevation (the angle from the center of the current unit to the center of our unit in the vertical axis) And:

Its bigger: Our projectile is again too far from a collision, remove the infidel at once

It equal or smaller: The fat bastard is dead on on the trajectory of our boolitz.

Last Cleanup:

In the end the last function should pass us a unit group with a couple or none units, if is the first one then get the closest target and get its center point, if its the latter then just get the height of the point at the maximum range

Shot the projectile or effect at this point

Fancy more Fancyness?

If you're a madman like myself you'll think this isn't enough, well the last thing i tried to do with this algorithm was to, once i had a suitable target, find "where" the shot went by performing an abridged version of the above code and look for custom points on the unit (pulled out from a hand-made list) representing soft spots like head, torso, legs, arms... etc. you can even apply special behaviors depending on where you get shot.

Note: Now, why would you bother with such a tiresome work, versus a "regular" traceline? Speed even with all the mathematical functions getting applied here you're still checking data (numbers) against other data, the heaviest of the work, both loops of the traceline and the enemy group are run just once, and we try to work with all the units in the unit group to find out if they're useful or not just once. This algorithm is made so it should at least be able to run 8 times per second, which is a decent machine gun speed. Add some smart caching of data and you can get the fabled 16 times per seconds, the only true limit.

And that pretty much was what i did... that was like a year ago now, so some details escape me, like was it tangent or secant for calculating the height of the final point, and so on...

BTW most of the math was pulled from a few posts from a single user here at SC2Mapster, cant remember the name or the link, but he has about 3 posts explaining his idea of just comparing angles instead of tracing line. Anyways the posts are like a "3d mouselook third person site:sc2mapster.com" google search away...

ok i tried to create shooting system for 3ps using cursor position as point, but i met a problem, i can't target AIR at all, if i target ground everything just goes fine, but when i target anything else, missiles are going to random position, is there way to fix it?

ok i found function that uses X,Y,Z coordinates as point, but still, its not working.

in theory it should work

your screen is 2D, how do you click at a 3D position?

add a text output with the values of x y and z and you will see what is wrong.

i deleted my old skype, contact me for new one. I am for hire now! My Legacy - All of my maps as open source

ok what "Mouse Z position clicked in the world" is for then? =) and why when i target skies missiles is actually going top? i don't understand hows this working at all. Is there way to get this done somehow?

yes, do some test!

use triggers to print the value of X - Y - Z position of the mouse each time. you will then see

what'swrong, then we might talk about why and how to solve it.i deleted my old skype, contact me for new one. I am for hire now! My Legacy - All of my maps as open source

ok i did, its mess of coordinates, so, how to solve it? =)

you missed the space between each element, but from what i can see the height is always the height of the X Y point you have clicked.

my idea would be to take the camera angle, point from x y and if you haven't skipped math calculate the point (or direction).

i deleted my old skype, contact me for new one. I am for hire now! My Legacy - All of my maps as open source

Anyone done it be4? :) sounds too hard for me

(Btw I just realized that I posted it in wrong forum, move it to triggers plz)

Let me share you my experience and maybe a second look at the implementation: I started doing a 3PS a while back for the heck of it and learned a few things (still have the file somewhere):

The way i did it (and worked wonderfully for me) was to compare the angle of attack and rotation of my camera, to the angle of attack and angle difference of each unit in the unit group comprising of all the units at most traceline distance of my unit.

That is:

Initial Angle:Traceline:Find Group:Refine Search:Last Cleanup:Fancy more Fancyness?If you're a madman like myself you'll think this isn't enough, well the last thing i tried to do with this algorithm was to, once i had a suitable target, find "where" the shot went by performing an abridged version of the above code and look for custom points on the unit (pulled out from a hand-made list) representing soft spots like head, torso, legs, arms... etc. you can even apply special behaviors depending on where you get shot.

Note: Now, why would you bother with such a tiresome work, versus a "regular" traceline? Speed even with all the mathematical functions getting applied here you're still checking data (numbers) against other data, the heaviest of the work, both loops of the traceline and the enemy group are run just once, and we try to work with all the units in the unit group to find out if they're useful or not just once. This algorithm is made so it should at least be able to run 8 times per second, which is a decent machine gun speed. Add some smart caching of data and you can get the fabled 16 times per seconds, the only true limit.And that pretty much was what i did... that was like a year ago now, so some details escape me, like was it tangent or secant for calculating the height of the final point, and so on...

BTW most of the math was pulled from a few posts from a single user here at SC2Mapster, cant remember the name or the link, but he has about 3 posts explaining his idea of just comparing angles instead of tracing line. Anyways the posts are like a "3d mouselook third person site:sc2mapster.com" google search away...

@gundrust: Go

Thanks a lot man!!