[General] Center a shadow on a unit

Status
Not open for further replies.
Does anyone know how to make a shadow have its center at the origin of the unit?

I have a dummy unit that right now is just a shadow (to make an object of changing height easier to recognize with depth perception)

The problem is not everyone has shadows enabled so I'd like to also put a small unit at the center of that shadow.
 
Well its a combination of Shadow Image X/Y and Shadow image Heigth/Width.

AFAIK the greater your Height/Width and hence the size of the shadow is the larger value for shadow imade X/Y you need to make it center.
 
The x and y in SetImagePosition(whichImage, x, y, z) are the coordinates of the lower left corner of the image.

If your image size is 64x64 for example

x = GetUnitX(u) + SquareRoot((64/2)^2+(64/2)^2)*Cos(-3*PI/4)
y = GetUnitY(u) + SquareRoot((64/2)^2+(64/2)^2)*Sin(-3*PI/4)

The unit's origin coordinates will be offset towards an angle of 225 degrees (angle from the origin to lower left corner) by half the diameter of the image.

Naturally you should precalculate the SquareRoot((64/2)^2+(64/2)^2)*Cos(-3*PI/4) and SquareRoot((64/2)^2+(64/2)^2)*Sin(-3*PI/4) because they will always be the same. Set them to a variable.
 
Status
Not open for further replies.
Back
Top