MoveCtrl Help
Posted: 06 Mar 2012, 09:50
A long time ago, the kind CarRepairer gave CT a sprint button and it worked just dandy. In a subsequent engine update, that broke.
Yeah I saw the mantis report about how you can't boost unit's speeds anymore, and that to achieve the same effect you raise the speed in the unitdef, reduce it in the script and then have it return to "normal" for your sprint function...
But this isn't working for me. I can get the unit to boost to it's increased speed for like... a second, then it returns to the slower "normal" speed. Sprint function is supposed to last for 10 seconds. Did some tests and found that the sprint function lasts the full 10 seconds, its just the speed modifiers that don't last.
Here are the relevant parts of the script:
What incredibly crucial thing am I missing/doing wrong?
Yeah I saw the mantis report about how you can't boost unit's speeds anymore, and that to achieve the same effect you raise the speed in the unitdef, reduce it in the script and then have it return to "normal" for your sprint function...
But this isn't working for me. I can get the unit to boost to it's increased speed for like... a second, then it returns to the slower "normal" speed. Sprint function is supposed to last for 10 seconds. Did some tests and found that the sprint function lasts the full 10 seconds, its just the speed modifiers that don't last.
Here are the relevant parts of the script:
Code: Select all
--variables
local speedFactor = 1
local normalFactor = 4
--locals
local myOrigSpeed = UnitDefs[unitDefID].speed
local myOrigAcc = UnitDefs[unitDefID].maxAcc
local myOrigTurnRate = UnitDefs[unitDefID].turnRate
--Sprint code
local function SprintEffects()
Signal(SIG_SPRINT)
SetSignalMask(SIG_SPRINT)
end
function StartSprint()
Spring.MoveCtrl.SetGroundMoveTypeData(unitID, {
maxSpeed = myOrigSpeed,
accRate = myOrigAcc,
turnRate = myOrigTurnRate,
})
StartThread(SprintEffects)
end
function StopSprint()
Spring.MoveCtrl.SetGroundMoveTypeData(unitID, {
maxSpeed = myOrigSpeed/normalFactor,
accRate = myOrigAcc/normalFactor,
turnRate = myOrigTurnRate/normalFactor,
})
Signal(SIG_SPRINT)
end
--End sprint code
--local functions
local function normal_speed()
Spring.MoveCtrl.SetGroundMoveTypeData(unitID, {
maxSpeed = myOrigSpeed/normalFactor,
accRate = myOrigAcc/normalFactor,
turnRate = myOrigTurnRate/normalFactor,
})
end
--script
function script.Create()
StartThread(normal_speed)
end