The reason this isn't working for a lot of people, especially those that aren't getting targets, is because of a particular line that makes it so "Closest Unit" can only target Player 15 units.
If you change the "15" to c_playerAny or your preferred hostile player, then it should start working for those that aren't getting targets.
It's an intuitive algorithm. Is there a reason Tan and stepping along the horizontal is better than Sine and stepping along the hypotenus? Using Sine would prevent errors at 90/270 degree angles.
Attack2EventsUI-Player1clicksLeftmousebuttonDown.LocalVariablesConditionsActionsTraceline(((Defaultgamecamera)target),traceline_currentTargetHeight[1],1)Trigger-Turn(Currenttrigger)OffVariable-SetAltMove_On=falseAnimation-PlayAttackanimationfor(ActorforMainUnit)asDefault,usingNoOptionsoptionsandDefaultTimeblendtimeSound-PlayAttackSoundfor(Allplayers)onMainUnitwithZoffset0.0(at100.0%volume,skipthefirst0.0seconds)Actor-CreateactormodelAttackModelatpoint(Point((MouseXpositionclickedintheworld),(MouseYpositionclickedintheworld)))General-If(Conditions)thendo(Actions)elsedo(Actions)Iftraceline_currentTarget[1]==NoUnitThenUI-Display"No unit targeted"for(Allplayers)toSubtitleareaElseUI-Display(Nameof(Unittypeoftraceline_currentTarget[1]))for(Allplayers)toSubtitleareaEnvironment-CreateAttackEffectontraceline_currentTarget[1]fromplayer1General-WaitAttackRateGameTimesecondsTrigger-Turn(Currenttrigger)On
I have some questions about traceline,
traceline runs great on the ground units,
but what about the unit on the high ground?
does that mean I have to set hitboxs for high ground units just like the air units?
Is traceline possible in multiplayer? Because when i duplicated traceline and rewrote the codes for the second player variables, my unit (player1) was using the targeting of the second player. That's my only problem with this, other than that its really AWESOME. Everything works fine, i just can't make another traceline for player 2, 3 and 4.
I am a total noob at this, but can somebody explain how to define boxes or whatever its called for the units. I copied the code, changed player 15 to any player like it said, and Im not sure what to do...
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
Hello, i am a bit aware of programming codes and i know a bit c and stuff similiar but i cant really find myself in that galaxy editor. I did all what rrowland said but it seems not working for me... do i have to create some custom lines to make "aiming" thingie at center of my screen or maybe it is made with traceline ? Ofcourse i need it for dealing damage to units i face with traceline.
---
somehow cuz of double + after C it is makin that text green and stuff kinda sucky =/
This trigger works great! I had managed to create my own "trace line" function without the z axis detected before but with your tutorial the last pieces of the puzzle were solved, thank you so much!
I'll credit you for this on my 3rd person shooter map/campagin im working on :D
Good tutorial, once I'm done with at least part of my UI then I'll try this out. I've got two questions through...
- So will this method work with vehicles that are constantly changing their height?
- This should be applicable to projectiles, correct? Or will this take up too much system space? I'd like to note that I don't have many doodads and fancy effects to take up system space.
- Will this collide with terrain as well? I.e. collide with a wall and thus kill itself.
I've done everything to the letter in the main post. But I am still getting a "Implicit cast not allowed" error on the "lv_closestUnit != gv_mainUnit &&" line. I cannot figure it out and, if I keep the line, cannot save the file. I'll remove the line for now, but I'm going to need to fix this and I don't know how. Again, I've followed everything to the letter yet I continue to get this error. I've also re-done this in a new testing-only map and it still doesn't work (because of this error, I cannot save it and show you the error). I've kept all the original names in this second map.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
The reason this isn't working for a lot of people, especially those that aren't getting targets, is because of a particular line that makes it so "Closest Unit" can only target Player 15 units.
If you change the "15" to c_playerAny or your preferred hostile player, then it should start working for those that aren't getting targets.
lv_closestUnit = libNtve_gf_ClosestUnitToPoint(lv_tracePoint, UnitGroup(null, 15, lv_traceRegion, UnitFilter(0, 0, (1 << c_targetFilterMissile), (1 << (c_targetFilterDead - 32)) | (1 << (c_targetFilterHidden - 32))), 0));
Good tutorial, should add a note in for that particular detail.
@onisagi: Go
Oops. Overlooked that.
@onisagi: Go
it works~ thx a lot :)
@robinjfor: Go
rrowland did most of the work.
It's an intuitive algorithm. Is there a reason Tan and stepping along the horizontal is better than Sine and stepping along the hypotenus? Using Sine would prevent errors at 90/270 degree angles.
LoL nice avatar with that wold xD.
So does FPS targeting(mouse look) works fine or ?
This you can adapt it to third person or first person. Works fine if you set up all the bounding boxes for units.
Im also having trouble with the target getting.
For me it says that "Expected a return value" how can I fix that.
Trigger - Turn (Current trigger) Off
For what is that? Because of it it doesn't work :D
I have some questions about traceline, traceline runs great on the ground units, but what about the unit on the high ground? does that mean I have to set hitboxs for high ground units just like the air units?
thx :)
I have pretty much no experience with scripting, so it comes as no surprise to me that I can't get this to work (cuz I'm a noob. XD)
Anyway, I followed your instructions, but I keep getting this error:
Script failed to compile: Syntax error (See Trigger Editor for more details)
And then it highlights: lv_traceHeight = Tan(lv_pitch) * lv_traceDistance * (-1);
What's the problem and how do I fix it?
Can someone post a WORKING example of this? I can't get it to work on my map. Thanks!
Is traceline possible in multiplayer? Because when i duplicated traceline and rewrote the codes for the second player variables, my unit (player1) was using the targeting of the second player. That's my only problem with this, other than that its really AWESOME. Everything works fine, i just can't make another traceline for player 2, 3 and 4.
Whenever I try to implant this and save I get
Implicit cast not allowed line 106 lv_closestUnit != gv_player_Units &&
and Syntax error line 110 gv_traceline_currentTarget[lp_player] = lv_closestUnit;
player_Units is my array with 4 units, any ideas?@rrowland: Go
Trying to get traceline working here... not sure what is wrong, but I don't think a target is being stored.
Perhaps someone could take a look? :D
I am a total noob at this, but can somebody explain how to define boxes or whatever its called for the units. I copied the code, changed player 15 to any player like it said, and Im not sure what to do...
Hello, i am a bit aware of programming codes and i know a bit c and stuff similiar but i cant really find myself in that galaxy editor. I did all what rrowland said but it seems not working for me... do i have to create some custom lines to make "aiming" thingie at center of my screen or maybe it is made with traceline ? Ofcourse i need it for dealing damage to units i face with traceline.
---somehow cuz of double + after C it is makin that text green and stuff kinda sucky =/
This trigger works great! I had managed to create my own "trace line" function without the z axis detected before but with your tutorial the last pieces of the puzzle were solved, thank you so much! I'll credit you for this on my 3rd person shooter map/campagin im working on :D
Good tutorial, once I'm done with at least part of my UI then I'll try this out. I've got two questions through...
- So will this method work with vehicles that are constantly changing their height?
- This should be applicable to projectiles, correct? Or will this take up too much system space? I'd like to note that I don't have many doodads and fancy effects to take up system space.
- Will this collide with terrain as well? I.e. collide with a wall and thus kill itself.
Sorry for the double post...
I've done everything to the letter in the main post. But I am still getting a "Implicit cast not allowed" error on the "lv_closestUnit != gv_mainUnit &&" line. I cannot figure it out and, if I keep the line, cannot save the file. I'll remove the line for now, but I'm going to need to fix this and I don't know how. Again, I've followed everything to the letter yet I continue to get this error. I've also re-done this in a new testing-only map and it still doesn't work (because of this error, I cannot save it and show you the error). I've kept all the original names in this second map.