HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Turning a unit with no movement

05-31-2006, 03:49 PM#1
iNfraNe
Hello,

I'm trying to use SetUnitFacing on a unit with 0 movement speed. This seems not possible. Is there any way to achieve still being able to turn a unit without it having movement? (I'd like to hide the UI abilities too).
05-31-2006, 03:50 PM#2
Whitehorn
Root / turret bone?
05-31-2006, 03:53 PM#3
iNfraNe
Could do that, but im really trying to avoid that :) I'm already moving a max of 8*20 units with triggers, im trying to keep units down. Using LookAt will mean I have to create a dummy for it to look at and move it around.
05-31-2006, 04:01 PM#4
Whitehorn
Hmm, have you tried negative movement? or would that make it go backwards?

What actually stops it moving? Could you give it 1 speed and then apply a -1 modifier? Or permanent immobility.
05-31-2006, 04:06 PM#5
Freakazoid
How about to set the movement type to NONE, and move speed to 10 or 20
05-31-2006, 04:27 PM#6
iNfraNe
Quote:
Originally Posted by Freakazoid
How about to set the movement type to NONE, and move speed to 10 or 20
That doesnt work.

I tried with -1 as movement speed. All it did was make the unit unable to move. Not hide the UI. But if thats the best option I have i guess ill have to take it.
05-31-2006, 05:51 PM#7
Rising_Dusk
Collapse JASS:
call UnitRemoveAbility(unit, 'Amov') // Removes Movement Ability
call UnitRemoveAbility(unit, 'Aatk') // Removes Attack Ability
Those should still allow you to set rotation, just leave their movement speed at like 300~ or whatever, then do this and they can't move.

Collapse JASS:
//***************************************************************************************************************
//*This function updates a unit's rotation.
//*Basically, this causes a unit to spin around in circles for a set duration.
//*
function RotateUpdate takes nothing returns nothing
    local timer rot = GetExpiredTimer()
    local unit u = GetUnit(rot, "u")
    local real dec = GetReal(rot, "dec")
    local real dur = GetReal(rot, "dur")
    local real indextime = GetReal(rot, "i")
    call SetUnitFacing(u, GetUnitFacing(u)+dec)
    call SetReal(rot, "i", indextime+.033)
    if indextime >= dur then
        call FlushLocals(rot)
        call DestroyTimer(rot)
    endif
    set u = null
endfunction

//***************************************************************************************************************
//*This function just starts the whole unit rotation thing. Read above for more info.
//*
function Rotate takes unit u, real rotationspeed, real duration returns nothing
    local timer rot = CreateTimer()
    call SetReal(rot, "i", 0.0)
    call SetReal(rot, "dur", duration)
    call SetReal(rot, "dec", rotationspeed)
    call SetHandle(rot, "u", u)
    call TimerStart(rot, .033, true, function RotateUpdate)
endfunction

It's impossible from my testing to simulate bladestorm like rotations.
But you can get pretty close using this function series.

Hope these helped! ^_^
05-31-2006, 06:05 PM#8
iNfraNe
Well dude thank you. I was about to test removing the ability with triggers myself. Thanks for telling me it works :)

The code was really not needed tho, but thanks anyway.
05-31-2006, 06:14 PM#9
Rising_Dusk
Meh, I had no idea how much you needed.
So I just threw out everything I knew. :P

And it's always a pleasure to help.