• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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.
 
Level 24
Joined
Oct 12, 2008
Messages
1,783
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.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
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.
Top