• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Placing a unit on another unit without collision.

Status
Not open for further replies.
Level 7
Joined
Aug 19, 2009
Messages
278
How to place a dummy unit exactly on another unit.

The dummy unit doesn't have collision. It has locust ability, is flying and invulnerable. Its just a simple circle model.

But when i place it on another unit on land. The dummy moves a little from the original position.

If I remove the ground units collision size, the dummy fits exactly on top. But I don't want to do that. I want that dummy unit to be a aura like thing. How is it possible?
 
In JASS and GUI

You need to create it, disable its collision, and move it to the desired location.
JASS:
function PlaceDummy takes real x,real y,integer id,player P returns nothing
    local unit U=CreateUnit(P,id,0,0,0)
    call SetUnitPathing(U,false)
    call SetUnitPosition(U,x,y)
    set U=null
endfunction
Something like that.

  • Set TempLoc = Point(0.00, 0.00)
  • Unit - Create 1 Dummy for Player at TempLoc facing 0.00 degrees
  • Unit - Turn collision for (Last created unit) Off
  • Unit - Move (Last created unit) instantly to (TempLoc)
  • Custom script: call RemoveLocation(udg_TempLoc)
  • Custom script: set udg_TempLoc=null
 
Level 7
Joined
Aug 19, 2009
Messages
278
Why do you even need a dummy unit? Surely some special effects would suffice?

The effect need to visible to only one player

You need to create it, disable its collision, and move it to the desired location.
JASS:
function PlaceDummy takes real x,real y,integer id,player P returns nothing
    local unit U=CreateUnit(P,id,0,0,0)
    call SetUnitPathing(U,false)
    call SetUnitPosition(U,x,y)
    set U=null
endfunction
Something like that.

  • Set TempLoc = Point(0.00, 0.00)
  • Unit - Create 1 Dummy for Player at TempLoc facing 0.00 degrees
  • Unit - Turn collision for (Last created unit) Off
  • Unit - Move (Last created unit) instantly to (TempLoc)
  • Custom script: call RemoveLocation(udg_TempLoc)
  • Custom script: set udg_TempLoc=null

Doesn't work for me
 
Level 7
Joined
Aug 19, 2009
Messages
278
Which method did you try? and the JASS version is the one i use, which has always worked for me. Maybe try splitting SetUnitPosition into SetUnitX and SetUnitY?

I tried the jass version not exactly your one. I used SetUnitX and SeunitY may be your one might work.
 
Level 7
Joined
Aug 19, 2009
Messages
278
So use GetLocalPlayer to alter the effect model path. That way you can create invisible models for all but the wanted players. All players need to have the string cached otherwise they will split but this can be done at map initialization.

I have used localplayer but made transparency 0 for other players. What is caching string?


edit---

What does ghost ability do?
 
Last edited:
Caching:
JASS:
function CreateLocalSFX takes player P,real X,real Y,string sfx returns effect
    if P!=GetLocalPlayer()then
        set sfx=""
    endif
    return AddSpecialEffect(sfx,X,Y)
endfunction

The desync issue is if you start with a blank string ("") and if the GetLocalPlayer() is the player you want, you set it to the correct string, this is wrong, it should start out as the model you want, and set it to a blank string if the local player isn't the one you want.
 
Level 7
Joined
Aug 19, 2009
Messages
278
Caching:
JASS:
function CreateLocalSFX takes player P,real X,real Y,string sfx returns effect
    if P!=GetLocalPlayer()then
        set sfx=""
    endif
    return AddSpecialEffect(sfx,X,Y)
endfunction

The desync issue is if you start with a blank string ("") and if the GetLocalPlayer() is the player you want, you set it to the correct string, this is wrong, it should start out as the model you want, and set it to a blank string if the local player isn't the one you want.

I didn't understand. And what does this jass function do?
 
Level 7
Joined
Aug 19, 2009
Messages
278
If ur not sure what it does how did u use the getlocalplayer b4? And as zeatherann said it changed the model string to 0 for all players that are not the player that u want to show the unit to.

I did this.

JASS:
    call SetUnitVertexColor(udg_circle, PercentToInt(100, 255), PercentToInt(100, 255), PercentToInt(100, 255), PercentToInt(100.0-100, 255))
    if (GetLocalPlayer() == Player(0)) then
    call SetUnitVertexColor(udg_circle, PercentToInt(100, 255), PercentToInt(100, 255), PercentToInt(100, 255), PercentToInt(100.0-0, 255))
    endif

I had read it somewhere in forums. Don't know if this works though.


I cant make that model vanish cause it should work for other players. I only want to make one unit(with that model) vanish and appear only to one player to whom it belongs.
 
Level 7
Joined
Aug 19, 2009
Messages
278
The model doesn't vanish u just basically hide it for the other players. So they can't see it.

I am telling what my trigger does. That way you can understand better.

When a player selects a unit, It is deselected immediately and a circle appears on the feet of the unit. No one except that player who has selected the unit can see it.

It is same with other players. If they select another unit only they can see the circle below there feet.

Wont my trigger do the work? Is there any other way to do this cause i can't find out a way to place the circle unit just exactly at the feet of the selected unit. It moves a little due to the selected units collision size even though circle doesn't have any collision.
 
JASS:
function CreateCircle takes player P,unit T returns effect
    // P is the player you want to see the circle.
    // T is the unit the circle is attatched to.
    // Returns created circle handle.
    local string S="UI\\Feedback\\Target\\Target.mdx"
    if P!=GetLocalPlayer()then
        set S=""
    endif
    return AddSpecialEffectTarget(S,T,"origin")
endfunction

Then simply do this: set New_Circle=CreateCircle(Player_That_Selected_Unit,Unit_That_Is_Selected) and it'll give you the circle for that player only.

The model string "UI\\Feedback\\SelectionCircleEnemy\\SelectionCircleEnemy.mdx" works well too. These were given to light by ap0calypse at This Thread.
 
Level 7
Joined
Aug 19, 2009
Messages
278
JASS:
function CreateCircle takes player P,unit T returns effect
    // P is the player you want to see the circle.
    // T is the unit the circle is attatched to.
    // Returns created circle handle.
    local string S="UI\\Feedback\\Target\\Target.mdx"
    if P!=GetLocalPlayer()then
        set S=""
    endif
    return AddSpecialEffectTarget(S,T,"origin")
endfunction

Then simply do this: set New_Circle=CreateCircle(Player_That_Selected_Unit,Unit_That_Is_Selected) and it'll give you the circle for that player only.

The model string "UI\\Feedback\\SelectionCircleEnemy\\SelectionCircleEnemy.mdx" works well too. These were given to light by ap0calypse at This Thread.

Ah awesome thanks... But I should save the effect in a variable if i have to remove it later?
 
Level 7
Joined
Aug 19, 2009
Messages
278
Yes, to clean it up later.

The effect doesn't gets removed. Even if I remove it, the animation still plays.

JASS:
function CreateCircle takes player P,unit T returns effect
    local string S="UI\\Feedback\\SelectionCircleEnemy\\SelectionCircleEnemy.mdx"
    if P!=GetLocalPlayer()then
        set S=""
    endif
    return AddSpecialEffectTarget(S,T,"origin")
endfunction

JASS:
    call CreateCircle(Player(0), test)
    set udg_se = bj_lastCreatedEffect
    call DestroyEffect(udg_se)

I tried destroying it just below the trigger but it doesn't gets removed. The animation still plays.
 
Level 7
Joined
Aug 19, 2009
Messages
278
JASS:
function Trig_MiscTarget_Actions takes nothing returns nothing
    local unit test
    set test = GetTriggerUnit()
    if test == udg_Player then
    return
    endif
    if test == udg_Target then
    return
    endif
    set udg_Target =  test
    set udg_Unitselected = 1.00
    call SelectUnit(test, false)
    call SelectUnit(udg_Player, true)
    call CreateCircle(Player(0), test)
    set udg_se = bj_lastCreatedEffect
    call DestroyEffect(udg_se)
    endfunction

and

JASS:
library createcircle
function CreateCircle takes player P,unit T returns effect
    local string S="UI\\Feedback\\SelectionCircleEnemy\\SelectionCircleEnemy.mdx"
    if P!=GetLocalPlayer()then
        set S=""
    endif
    return AddSpecialEffectTarget(S,T,"origin")
endfunction
endlibrary

Circle is created but cannot be destroyed.
 
Level 7
Joined
Aug 19, 2009
Messages
278
this is because u r trying to use GUI as JASS.
here is ur problem.
JASS:
    call CreateCircle(Player(0), test)
    set udg_se = bj_lastCreatedEffect
    call DestroyEffect(udg_se)
change to this
JASS:
    set udg_se = CreateCircle(Player(0), test)
    call DestroyEffect(udg_se)

in jass u never need Bj_last created anything


It works not but it takes quite some time to vanish. Can any model editor fix it with a imported model?
 
Status
Not open for further replies.
Top