Is there a way to know what side of a unit is being attacked? Or is there a way to assume what side is being attacked? For instance if a unit A takes damage from a missile fired from another unit B, can you check the location on the map of unit B and compare to unit A to assume it was behind you at the point of impact so you take damage to the rear?
How do you only allow a unit to shoot when their weapon is facing the target? I notice the Goliath in SC rotates as it is tracking but when the target goes out of that rotation the Goliath model then turns very quickly to point at the target. I want to prevent a unit/model from doing this quick motion and force the player to control the unit into the range of fire of the weapon.
Checking the location of the attacker in script is quite easy. You can check the attacking/damaging unit, get its location, the location of the triggering unit as well. Rest is just calculation, not sure, which native calculation functions there are, but you can easily take x and y values and use trigonometrics to compare angles.
If you just want to check, if the attacker is behind the target, you can even use a data-only validator (source)
I am not sure, what you want to do with your units: It should only shoot in a specific angle, but not turn any further automatically?
Not sure, how I would realize it, either; I would probably go for some kind of workaround; like make the unit stationary when not moving, so it actually cannot turn, if you don't order it to (easiest way to do this would be a set up ability like siege tanks - this can probably be automatized and somehow be "released" when giving a move order; at least its worth a try). This is all pure theorycrafting, though.
Is there a way to know what side of a unit is being attacked? Or is there a way to assume what side is being attacked? For instance if a unit A takes damage from a missile fired from another unit B, can you check the location on the map of unit B and compare to unit A to assume it was behind you at the point of impact so you take damage to the rear?
How do you only allow a unit to shoot when their weapon is facing the target? I notice the Goliath in SC rotates as it is tracking but when the target goes out of that rotation the Goliath model then turns very quickly to point at the target. I want to prevent a unit/model from doing this quick motion and force the player to control the unit into the range of fire of the weapon.
Checking the location of the attacker in script is quite easy. You can check the attacking/damaging unit, get its location, the location of the triggering unit as well. Rest is just calculation, not sure, which native calculation functions there are, but you can easily take x and y values and use trigonometrics to compare angles.
If you just want to check, if the attacker is behind the target, you can even use a data-only validator (source)
I am not sure, what you want to do with your units: It should only shoot in a specific angle, but not turn any further automatically?
Not sure, how I would realize it, either; I would probably go for some kind of workaround; like make the unit stationary when not moving, so it actually cannot turn, if you don't order it to (easiest way to do this would be a set up ability like siege tanks - this can probably be automatized and somehow be "released" when giving a move order; at least its worth a try). This is all pure theorycrafting, though.