This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
Just remember to switch Hero to your character id, HeroWalkX animation names to your walk animations ids and MainHeroOutfit to your character outfit id. Also depending on your resolution tweak minSpeed and fullWalkSpeed variables.
Also I wrote 360-23 etc. instead of 337 because it's more obvious what it means
feel free to change that as well.
fullWalkSpeed = 300
minSpeed = 100function OnMainLoop()
if( getObject( "Characters[Hero]" ):getInt( VCharacterState )==3 ) then
local direction = getObject("Characters[Hero]"):getInt(VCharacterDirection)
if( direction > 360-23 or direction < 23 ) then
weight = getObject("ActiveAnimations[HeroWalkE]"):getInt(VAnimationSize)
elseif( direction > 315-23) then
weight = getObject("ActiveAnimations[HeroWalkSE]"):getInt(VAnimationSize)
elseif( direction > 270-23) then
weight = getObject("ActiveAnimations[HeroWalkS]"):getInt(VAnimationSize)
elseif( direction > 225-23) then
weight = getObject("ActiveAnimations[HeroWalkSW]"):getInt(VAnimationSize)
elseif( direction > 180-23) then
weight = getObject("ActiveAnimations[HeroWalkW]"):getInt(VAnimationSize)
elseif( direction > 135-23) then
weight = getObject("ActiveAnimations[HeroWalkNW]"):getInt(VAnimationSize)
elseif( direction > 90-23) then
weight = getObject("ActiveAnimations[HeroWalkN]"):getInt(VAnimationSize)
elseif( direction > 45-23) then
weight = getObject("ActiveAnimations[HeroWalkNE]"):getInt(VAnimationSize)
end
weight=weight/100.0
getObject("Outfits[MainHeroOutfit]"):setValue(VOutfitCharacterSpeed,weight*fullWalkSpeed+minSpeed)
end
end
registerEventHandler("mainLoop", "OnMainLoop")
The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license. Until 1 Dec 2026 all licenses are 30 % off, for example the Indie Bundle for €69.30 instead of €99. The code BLACKFRIDAY is applied automatically at checkout.
See licenses Try it for free-- let's create some initial variables
local minSpeed = 120 -- min speed value
local maxSpeed = 350 -- approx normal walking speed value
local initialTime = getTime() -- store the initial time of the timer
local targetTime = 500 -- set target time in ms (to prevent setWalkSpeed from being called 100's of times in under a second)
-- let's create the function in which we set the walk speed of the current character
function setWalkSpeed()
tblWalk = {}
tblWalk["_temporary_"] = ""
tblWalk[1] = game:getLink(VGameCurrentCharacter) -- store current character
tblWalk[2] = tblWalk[1]:getInt(VCharacterSize) / 100 -- store current character scale & divide by "100"
tblWalk[3] = tblWalk[1]:getLink(VCharacterCurrentOutfit) -- store current character outfit
tblWalk[4] = tblWalk[3]:getInt(VOutfitCharacterSpeed) -- store current outfit speed
tblWalk[5] = tblWalk[2] * maxSpeed + minSpeed -- calculate the new walk speed
-- * break * --
if tblWalk[5] > maxSpeed then tblWalk[5] = maxSpeed end -- check if walk speed is more than max speed
if tblWalk[4] ~= tblWalk[5] then tblWalk[3]:setValue(VOutfitCharacterSpeed, tblWalk[5] ) end -- set the new walk speed
end
-- let's create the onMainLoop function in which we store functions we want to loop
function onMainLoop()
if (game:getLink(VGameCurrentCharacter):getInt(VCharacterState) == 3) and (getTime() >= initialTime + targetTime) then -- is character walking & has the timer elapsed a specific time?
getTime({flags=1, reset=true}) -- reset the timer back to 0
setWalkSpeed() -- call walk speed function
end
end
-- let's create the mainLoop handler
registerEventHandler("mainLoop", "onMainLoop")
02:50:23: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:24: the mainLoop handler loops rapidly
02:50:25: the mainLoop handler loops rapidly
02:50:25: the mainLoop handler loops rapidly
02:50:25: the mainLoop handler loops rapidly
-- * begin walk speed code * --
-- let's create some initial variables
local minSpeed = 120 -- min speed value
local maxSpeed = 350 -- approx normal walking speed value
-- let's create the function in which we set the walk speed of the current character
function setWalkSpeed()
tblWalk = {} -- empty table
tblWalk["_temporary_"] = "" -- set as temporary table
tblWalk[1] = game:getLink(VGameCurrentCharacter) -- store current character
tblWalk[2] = tblWalk[1]:getInt(VCharacterSize) / 100 -- store current character scale & divide by "100"
tblWalk[3] = tblWalk[1]:getLink(VCharacterCurrentOutfit) -- store current character outfit
tblWalk[4] = tblWalk[3]:getInt(VOutfitCharacterSpeed) -- store current outfit speed
tblWalk[5] = tblWalk[2] * maxSpeed + minSpeed -- calculate the new walk speed
-- * break * --
if tblWalk[5] > maxSpeed then tblWalk[5] = maxSpeed end -- check if walk speed is more than max speed
if tblWalk[4] ~= tblWalk[5] then tblWalk[3]:setValue(VOutfitCharacterSpeed, tblWalk[5] ) end -- set the new walk speed (only if new speed is not same as current speed value)
end
-- * end walk speed code * --
This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.
New threadDeponia, The Whispered World and more than 160 other games were made with Visionaire Studio. The free version covers up to 25 scenes. For more scenes there is Visionaire Studio PRO from €75, and to sell your game the Indie Bundle for €99.
Through December 1: all licenses 30% off, for example the Indie Bundle for €69.30 instead of €99. Applied automatically at checkout.