I realized instantiating it would have a problem because it is an image and needs to get onto the UnitWorldUI. Instead of doing that, I just added an image to the enemy UnitWorldUI and made it public in Unit.cs
and added LookAtCamera.cs
. That’s all working fine, but I can’t seem to figure out how to adjust its position so that it moves to the right place between the shooter and the target.
Currently I have it like this:
targetUnit.preciseScope.transform.localPosition -= (targetUnit.transform.localPosition - unit.transform.localPosition).normalized;
but this is a little bit off when behind and very off when in front. When in front it’s better to add instead of subtract, so maybe adding an if statement where if the difference is above zero then switch it to add would help, but that still doesn’t help it from being off-center. I’m not sure the best way to adjust the position so that it is always in the center between the shooter and target. I have tried all kinds of addition, subtraction, normalized, not normalized, and so on.