title says it all, any ideas to validate if there is another unit between caster and target. data only solution needed for weapon.
Currenty i am using a combi-validator with OR to validate if there are units from caster towards target and if there are units from the target towards the caster.
If this is for some kind of line-AoE/colliding missile you can work it into the weapon/ability itself, for more abstract cases the Validator sounds like the smartest solution. The way you phrase it the combine type should be AND though, as you want units that are in front of both caster and target, OR should yield the entire line through those 2 points.
the thing is, if the target is very close and a unit is behind the target the first validator will give an error, same thing vice versa for caster, that's why it is a OR. if one validator says there is no unit between then there is no unit between, but if both validator say there might be a unit between there might be no unit between (sounds strange lol, but i mean it).
yes it's for a weapon with projectiles. most basic example, there is a enemy behind a car, then the unit shall not attack because it wont hit the target. but as i have it set now if there is a car behind the caster and behind the target it wont attack neither.
i could have many validators (for each range possible) but that sucks.
RTS games are not really built for this kind of test because it needs a vision algorithm which tracks each unit separately. It is probably impossible to do efficiently as I do not see how the data would be able to find valid targets without excessive resource consumption (constantly re*validating each target nearby).
If the validator is inaccurate that's nothing we can fix. Can you do a direct comparison of the direct "A and B" vs. the mathematically equivalent "Not( NotA or NotB)"? (where A is one direction check and B is the other)
While you can't easily prevent firing this way, and it's certainly inefficient for long, narrow lines on many units, you could make an instant-hit line AoE preceding the actual attack. If it finds any obstruction prevent the main weapon effect or cause it to impact the first obstruction found. The unit would still stand there wasting its weapon cooldown though, as well as the Cost of said weapon if you're using that to simulate ammo or something. The advantage is that with Persistent Offsets you can define pretty much any arbitrary shape by approximating it with small circles.
I think you can create a dummy missile that stops when it hits any unit.
You can use things like impact effects, periodic effects on the missile itself, etc to do a lot with that.
Like you can have the unit attack anyway but not have the bullets hit the target (they hit the car first).
You can try thing with validators too, but no idea if they'd work:
Validate that there are no units with a distance from the caster less than the distance from the caster to the target && the distance between the caster and unit + the distance between the target and unit must approximate (can you have +- in validators) the distance between the caster and target.
that's exactly what i was looking for, combinating both of my validators within is the solution. there wont be too many units around with this weapon, so it shouldn't lag too much.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
hello there,
title says it all, any ideas to validate if there is another unit between caster and target. data only solution needed for weapon.
Currenty i am using a combi-validator with OR to validate if there are units from caster towards target and if there are units from the target towards the caster.
If this is for some kind of line-AoE/colliding missile you can work it into the weapon/ability itself, for more abstract cases the Validator sounds like the smartest solution. The way you phrase it the combine type should be AND though, as you want units that are in front of both caster and target, OR should yield the entire line through those 2 points.
the thing is, if the target is very close and a unit is behind the target the first validator will give an error, same thing vice versa for caster, that's why it is a OR. if one validator says there is no unit between then there is no unit between, but if both validator say there might be a unit between there might be no unit between (sounds strange lol, but i mean it).
yes it's for a weapon with projectiles. most basic example, there is a enemy behind a car, then the unit shall not attack because it wont hit the target. but as i have it set now if there is a car behind the caster and behind the target it wont attack neither.
i could have many validators (for each range possible) but that sucks.
RTS games are not really built for this kind of test because it needs a vision algorithm which tracks each unit separately. It is probably impossible to do efficiently as I do not see how the data would be able to find valid targets without excessive resource consumption (constantly re*validating each target nearby).
If the validator is inaccurate that's nothing we can fix. Can you do a direct comparison of the direct "A and B" vs. the mathematically equivalent "Not( NotA or NotB)"? (where A is one direction check and B is the other)
While you can't easily prevent firing this way, and it's certainly inefficient for long, narrow lines on many units, you could make an instant-hit line AoE preceding the actual attack. If it finds any obstruction prevent the main weapon effect or cause it to impact the first obstruction found. The unit would still stand there wasting its weapon cooldown though, as well as the Cost of said weapon if you're using that to simulate ammo or something. The advantage is that with Persistent Offsets you can define pretty much any arbitrary shape by approximating it with small circles.
What you trying to do?
I think you can create a dummy missile that stops when it hits any unit.
You can use things like impact effects, periodic effects on the missile itself, etc to do a lot with that.
Like you can have the unit attack anyway but not have the bullets hit the target (they hit the car first).
You can try thing with validators too, but no idea if they'd work:
Validate that there are no units with a distance from the caster less than the distance from the caster to the target && the distance between the caster and unit + the distance between the target and unit must approximate (can you have +- in validators) the distance between the caster and target.
@QuantumMenace: Go
that's exactly what i was looking for, combinating both of my validators within is the solution. there wont be too many units around with this weapon, so it shouldn't lag too much.