Hello, I have been working on project with the idea of "Commandos" if you have played it. I have done the terrain and some heroes but i got stack on the arc vision of units. What I want to do is make the enemy units only attack if the unit is in an arc of vision. Let's say the arc is 180º, this will make the unit only attack units coming from the front and sides, so if a unit passes by at it's back it will not turn neither attack.
I tryed to do so with a buff and changing detection arc but it doesn't get to work, thank you all, you are awesome.
I have some ideas: Try setting AquirePrioritization ( < - - raw-data name, don't know the usual English name) to "Angle"
Set the Weapon-Arc to the arc you want. So let's say 90° would mean 45° to the left and right, normal for a human would be something between 180 and 0° :D
And then set the range of the weapon as high as you want it.
I am not sure what the "minimal scanrange" is.. Maybe this one needs to be adjusted too.
Also another idea would be to play around with the field "AcquireTargetSorts" (again raw -data-name). If you add a sort which prefers the arc and set this to 100% then the weapon may only pick units in the angle of vision.
I am pretty sure that the weapon (the unit) will attack units in their vision first, but I am not sure if it will still turn to be able to attack a unit which is behind it.
It doesn't get to work, doing those things make the unit to not turn if you shoot it out of its range (and that was the only condition I wanted for turning D:)
But in the moment you get in the sight range it turns and shoots.
You could fix that by adding a trigger in the lines of "unit takes damage" (ENemy players only) then issue order, attack "attacking unit" that should force it to turn. This way if you fixed the only attack in the arc in front of the enemies fine, but if a player attacks the unit, it will turn and attack him.
What he means are soldiers that don't magically notice when a silent little assassin walks behind them. ;) Or can you see what's going on in your back?
But the game is based on this sort of detection (well, it won't be too hard to notice a tank or colossus behind you :D ), so you can only adjust the detection range, but not the arc.
A workaround would then be done with triggers. Set the basic detection range to 0 for all units, so they do not notice any enemy themselves, and do the AI with triggers. That will mean periodically looping through all units on the field. Having their detection range and arc stored in variables and checking if there is a unit in this arc. If there is one you can then order to attack in the trigger. That way it would also be possible to check if there is anything blocking the line of vision between the units.
Thank you for the explanation of the sight phisics Rushhour ;)
Ok I know a bit of trigger, just essential, spawning, giving orders, changing owner player... But I am not sure on how to do all you said, so some help with the events and the actions to use would be thankfull. Thanks and happy New Year by the way ;)
Ok, I made a library which should do the job. Was a little tricky since the game engine returns angle between points from -180° to 180° . So -180° is equal to 180°, this tricks the little math out. :(
But I think I got it now, I add the library. You just need to import it over the import manager and then you should be able to use it.
To add a unit to the system you will first of all need to disable the automatic detection of the weapon in the data editor. I used a marine for testing. In the marine's weapon I just removed all checkboxes for allies, enemies, neutral,... in the field "weapon scan filter". That makes the marine unable to attack by itself, but the weapon range and all is still the same.
To add the marine to the system you need then to call the function I added. "AddUnitToDetectionAi". The parameters should be self-explaining.
What angle is the best is up to you, I used 80° that would mean 40° to the right and to the left of the unit's facing.
Create a buff (behavior) on your unit, that periodically casts a Search Area Effect
Set the Search Area Arc to the sight angle (180° maybe). Be sure to set Impact Location and Launch Location to Caster Unit/Point, otherwise it would always assume your unit has a 0° facing. The Effect you apply to the found unit is up to you...
Hello, I have been working on project with the idea of "Commandos" if you have played it. I have done the terrain and some heroes but i got stack on the arc vision of units. What I want to do is make the enemy units only attack if the unit is in an arc of vision. Let's say the arc is 180º, this will make the unit only attack units coming from the front and sides, so if a unit passes by at it's back it will not turn neither attack.
I tryed to do so with a buff and changing detection arc but it doesn't get to work, thank you all, you are awesome.
PD: Sorry if my english level is bad :S
Your English's not bad, but you didn't give enough details.
Do you mean detection as in detecting invisible things or do you mean normal (sight) vision?
I mean sight, imagine a normal marine ok? the thing is to make him only attack if the enemy is in an especific angle of vision.
I have some ideas: Try setting AquirePrioritization ( < - - raw-data name, don't know the usual English name) to "Angle"
Set the Weapon-Arc to the arc you want. So let's say 90° would mean 45° to the left and right, normal for a human would be something between 180 and 0° :D
And then set the range of the weapon as high as you want it.
I am not sure what the "minimal scanrange" is.. Maybe this one needs to be adjusted too.
Also another idea would be to play around with the field "AcquireTargetSorts" (again raw -data-name). If you add a sort which prefers the arc and set this to 100% then the weapon may only pick units in the angle of vision.
I am pretty sure that the weapon (the unit) will attack units in their vision first, but I am not sure if it will still turn to be able to attack a unit which is behind it.
It doesn't get to work, doing those things make the unit to not turn if you shoot it out of its range (and that was the only condition I wanted for turning D:)
But in the moment you get in the sight range it turns and shoots.
You could fix that by adding a trigger in the lines of "unit takes damage" (ENemy players only) then issue order, attack "attacking unit" that should force it to turn. This way if you fixed the only attack in the arc in front of the enemies fine, but if a player attacks the unit, it will turn and attack him.
Fine but the problem is how I do to make them not to turn round when a enemy unit is sighted?
@YnScription: Go
You don't want them to turn towards the enemy when they see him, what kinda soldiers are this =S..
"You, that's an enemy here to kill me, I'll just keep looking the same way"
What he means are soldiers that don't magically notice when a silent little assassin walks behind them. ;) Or can you see what's going on in your back?
But the game is based on this sort of detection (well, it won't be too hard to notice a tank or colossus behind you :D ), so you can only adjust the detection range, but not the arc.
A workaround would then be done with triggers. Set the basic detection range to 0 for all units, so they do not notice any enemy themselves, and do the AI with triggers. That will mean periodically looping through all units on the field. Having their detection range and arc stored in variables and checking if there is a unit in this arc. If there is one you can then order to attack in the trigger. That way it would also be possible to check if there is anything blocking the line of vision between the units.
If you need help with this trigger tell me/us.
Thank you for the explanation of the sight phisics Rushhour ;)
Ok I know a bit of trigger, just essential, spawning, giving orders, changing owner player... But I am not sure on how to do all you said, so some help with the events and the actions to use would be thankfull. Thanks and happy New Year by the way ;)
Ok, I made a library which should do the job. Was a little tricky since the game engine returns angle between points from -180° to 180° . So -180° is equal to 180°, this tricks the little math out. :(
But I think I got it now, I add the library. You just need to import it over the import manager and then you should be able to use it.
To add a unit to the system you will first of all need to disable the automatic detection of the weapon in the data editor. I used a marine for testing. In the marine's weapon I just removed all checkboxes for allies, enemies, neutral,... in the field "weapon scan filter". That makes the marine unable to attack by itself, but the weapon range and all is still the same.
To add the marine to the system you need then to call the function I added. "AddUnitToDetectionAi". The parameters should be self-explaining.
What angle is the best is up to you, I used 80° that would mean 40° to the right and to the left of the unit's facing.
@YnScription: Go
Its far easier: