I created an animation gate. When destroyed console, the gate opens.
Question: how to make that when I fix the console, the gate closes?
Please explain in detail how to make it work.
Here is my lua script:
Hidden/Spoiler:
function ScriptPostLoad()
animateobja = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "gatelock" then
PlayAnimation("open")
RewindAnimation("open")
end
end
)
repairobja = OnObjectRepair(
function(object, repairer/characterId?!)
if GetEntityName(object) == "gatelock" then
RespawnObject("gatelock")
RewindAnimation("open")
end
end
)
I have created only one animation - opening the gate.
Please help!
RewindAnimation doesn't actually play the animation you specify backwards. All it does is instantaneously return the animated object to the first frame of the animation. What you want to do is create a second animation called, say, closed. This animation would have the same frames as the "open" animation, but with the frames in reversed order. Then use PlayAnimation("closed") instead of RewindAnimation("open").
I did as you said. But the animation does not occur.
Here is my lua:
Hidden/Spoiler:
function ScriptPostLoad()
animateobja = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "gatepanel" then
PlayAnimation("open")
end
end
)
repairobja = OnObjectRepair(
function(object, repairer)
if GetEntityName(object) == "gatepanel" then
PlayAnimation("closed")
end
end
)
Perhaps this is the wrong lua code?I replaced the animation "closed" in the code to "objectkill" and the animation is playing.
Works only animation "closed." I added the same line in the animation "open", but it does not work.
My lua:
Hidden/Spoiler:
animateobja = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "gatepanel" then
RewindAnimation ("open")
PlayAnimation("open")
end
end
)
OnObjectRespawn(
function (object)
if GetEntityName(object) == "gatepanel" then
RewindAnimation ("closed")
PlayAnimation("closed")
end
end
)
EDIT
Please reply!
No matter what I did, animations do not work.
Double posting is against the RULES; please EDIT your post instead -Staff
Your problem is that your animations don't play a second time, right?
Vanilla scripts often use PauseAnimation before rewinding them, maybe that helps: