I am able to use this sprite in Scene that will keep moving using Direction and I am able to set Rotation properly. (so it flies from attacking unit to defending unit)
The problem is that instead of moving this Scene, I want to make the sprite to appear between attacking unit and defending unit, so the animation can play and then damage will be done.
How to such effect? I was looking into Raycast2D, Line2D but could not find a way to resize the sprite and play the animation in such cases.
To sum it up, I have:
Target Position (+global position if needed)
Attacker Position (+global position if needed)
Rotation so sprite will be pointed from attacker to target
Direction from attacker to target which I would use if this was regular projectile
I somehow need to rescale the sprite so thunder is between target and attacker positions. And it does not move, just play animation
Im on my phone not computer or id write up the code, and i could be wrong. But i would try:
Get the midpoint between your 2 points (target position - attacker position) then divide that by 2 to get halfway. Make that your sprite position (as long as your sprite offset is in the middle of the sprite. Set the ration of the sprite (which you said you can do so ill skip that part. Then calculate the distance between the points with
(target position -attacker position).length()
That will get you the distance between the 2. Then you need to know the length of your sprite. So if its 100 and you have a length between the 2 points of 250 you would change the scale by 250/100 which would be 2.5 So whatever length you get from .length() divide it by the length of your sprite. And if you dont like scaling the entire lightning bolt because it would be thicker do just scale.x or scale.y
Hope that makes sense and hope its what ur asking for!