I have created this script for a bridge that play a animation when player is close.
local PlayerDist = 0
local AnimRun = 0
function bridge_init(e)
CollisionOff(e);
end
function bridge_main(e)
PlayerDist = GetPlayerDistance(e)
if AnimRun == 0 and PlayerDist < 600 then
SetAnimation(0);
SetAnimationSpeed(e,150);
SetAnimationFrames(0,150)
PlayAnimation(e);
PlaySound(e,0);
HurtPlayer(e,0);
AnimRun = 1
end
if AnimRun == 1 and PlayerDist > 1200 then
Destroy(e)
end
end
The script works but when the player is far from the entity, the animation has already played.
So if i come close the animation plays again.
Whats wrong with the script.
many thanks.
Harry
Harry