• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[General] Make unit Transparent

Status
Not open for further replies.
JASS:
call SetUnitVertexColor(whichUnit, red, green, blue, alpha)

Red, green, blue and alpha are integers between 0 and 255.
By reducing alpha you can make the unit transparent.
For example:

JASS:
call SetUnitVertexColor(u, 255, 255, 255, 127)

This will make u 50% transparent.
 
Or through this action in trigger:
  • Animation - Change (Triggering unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
 
This function only hides the unit, the shadow remains.

Did you know you can set a variable to the handle of a newly created image, then destroy the image, then create a unit and then that variable points to the shadow of the newly created unit?
This way you can move the shadow of the unit out of bounds or hide it. Also, both vertex coloring and moving the image out of bounds can be done locally for a player.
I'm not yet sure if it desyncs for showing images locally.
This way you can completely locally hide a unit for a player. But then again, this can also be accomplished with the windwalk ability.

Some time ago I got an example from Magtheridon96:
JASS:
function CreateUnitAndGetShadow takes nothing returns image     
    // Handle id of this image is now 0    
    local image i = CreateImage("dummy.blp", 64, 64, 0, 0, 0, 0, 64, 64, 0, 3)     
    // Image destroyed, i points to 0     
    call DestroyImage(i)     
    // This unit will also create an image (it's shadow)     
    // This shadow will have a Handle Id of 0     
    // i points to an image with Id 0     
    call CreateUnit(...)     
    // Thus i is now the actual shadow of the unit ^_^     
    return i 
endfunction


Some useful natives in this case.
JASS:
native CreateImage takes string file, real sizeX, real sizeY, real sizeZ, real posX, real posY, real posZ, real originX, real originY, real originZ, integer imageType returns image
native DestroyImage takes image whichImage returns nothing
native ShowImage takes image whichImage, boolean flag returns nothing
native SetImageConstantHeight takes image whichImage, boolean flag, real height returns nothing
native SetImagePosition takes image whichImage, real x, real y, real z returns nothing
native SetImageColor takes image whichImage, integer red, integer green, integer blue, integer alpha returns nothing
native SetImageRender takes image whichImage, boolean flag returns nothing
native SetImageRenderAlways takes image whichImage, boolean flag returns nothing
native SetImageAboveWater takes image whichImage, boolean flag, boolean useWaterAlpha returns nothing
native SetImageType takes image whichImage, integer imageType returns nothing

I hope this was useful to someone.
 
I tested your function and didn't work...

I figured out you only need to do this to retrieve the unit shadow:

JASS:
call CreateUnit( Player(0), 'hfoo', 0, 0, 270 )
set UnitShadow = bj_lastCreatedImage

You can also destroy the shadow when the unit is created:

JASS:
call CreateUnit( Player(0), 'hfoo', 0, 0, 270 )
call DestroyImage( bj_lastCreatedImage )

ShowImage(GetLastCreatedImage(), false) doesn't works, like trying to change the position of the shadow.- :/
In order to Show/Hide the shadow you need to use SetImageColor.
JASS:
//Show the Shadow
call SetImageColor( UnitShadow , 255, 255, 255, 255 )
//Hide the Shadow
call SetImageColor( UnitShadow , 0, 0, 0, 0 )
 
Last edited:
@Anvil:

Hmm then it seems Magtheridon96 was wrong on the function I showed.
Refference: https://www.hiveworkshop.com/forums/2083066-post43.html

The function is the same principle though, yours might refer to it more directly.
Magtheridon96's function not working might have something to do with referring to previously created handles (handle ID's messing up), but I suppose your approach is much better in this case.

Thanks a lot for testing that out, I didn't really have the time to go through it myself.

It's great to see how it works, thanks ;)
 
Status
Not open for further replies.
Back
Top