This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
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 freefunction compareCharDist(atk, def)
if Characters[atk].Position.x < Characters[def].Position.x and (Characters[def].Position.x - Characters[atk].Position.x) <= 100 then
-- hit (attacker is on left)
elseif if Characters[atk].Position.x > Characters[def].Position.x and (Characters[atk].Position.x - Characters[def].Position.x) <= 100 then
-- hit (attacker is on right)
end
endcompareCharDist("Tom", "Harry")I've been trying that setDelay example to see if I could detect when a character is in range and it seems to work well BUT I'm really not sure if its a good idea to have it running for an extended period of time also the range depends on how fast the delay runs.Hence check directly via the relevant animation frame. Why bother with delays, when you can sync much easier by checking on the relevant animation frames?a delay of 250ms is enough if you check for a a character 50px away..
startAnimation(Characters[def].CurrentOutfit.CharacterAnimations["hurt"])function compareCharDist(MC,opponent)
NearOpponentStandingRight = getObject("Conditions[NearOpponentStandingRight]")
NearOpponentStandingLeft = getObject("Conditions[NearOpponentStandingLeft]")
if Characters[MC].Position.x < Characters[opponent].Position.x and (Characters[opponent].Position.x - Characters[MC].Position.x) <= 100 then
setCondition("nearEnough", true)
NearOpponentStandingLeft:setValue(VConditionValue, true)
NearOpponentStandingRight:setValue(VConditionValue, false)
-- hit (attacker is on left)
elseif
Characters[MC].Position.x > Characters[opponent].Position.x and (Characters[MC].Position.x - Characters[opponent].Position.x) <= 100 then
setCondition("nearEnough", true)
NearOpponentStandingRight:setValue(VConditionValue, true)
NearOpponentStandingLeft:setValue(VConditionValue, false)
-- hit (attacker is on right)
end
end
compareCharDist("MC", "opponent")function distanceScriptTry (mc, opponent)
standingRight = getObject("Conditions[standingRight]")
standingLeft = getObject("Conditions[standingLeft]")
mc = getObject("Characters[MC]")
opponent = getObject("Characters[opponent]")
if mc.Position.x + opponent.Position.x >=1
and
mc.Position.x + opponent.Position.x <=300
then
standingRight:setValue(VConditionValue, true)
else
standingRight:setValue(VConditionValue, false)
end
if mc.Position.x - opponent.Position.x <=-1
and
mc.Position.x - opponent.Position.x >=-300
then
standingLeft:setValue(VConditionValue, true)
else
standingLeft:setValue(VConditionValue, false)
end
end
function distanceScriptTry (mc, opponent)
standingRight = getObject("Conditions[standingRight]")
standingLeft = getObject("Conditions[standingLeft]")
mc = getObject("Characters[MC]")
opponent = getObject("Characters[opponent]")
if mc.Position.x < opponent.Position.x
and
mc.Position.x - opponent.Position.x >=-300
then
standingLeft:setValue(VConditionValue, true)
else
standingLeft:setValue(VConditionValue, false)
end
if mc.Position.x > opponent.Position.x
and
mc.Position.x - opponent.Position.x <=300
then
standingRight:setValue(VConditionValue, true)
else
standingRight:setValue(VConditionValue, false)
end
end
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.