I’m working through the war battles tutorial and I’ve got a problem with the explosions. i haven’t added in the tanks yet so the rockets are just working on the timer. when the timer gets to 0 the rocket object stops moving and rotates to 0 as it should, but the sprite doesnt change to the explosion. I get this error message -
ERROR:GAMEOBJECT: Component ‘/instance0#sprite’ could not be found when dispatching message ‘play_animation’ sent from main:/instance0#rocket1
this is the code on the rocket script by the way -
function update(self, dt)
local pos = go.get_position()
pos = pos + self.dir * self.speed * dt
go.set_position(pos)
self.life = self.life - dt
if self.life < 0 then
self.life = 1000
go.set_rotation(vmath.quat())
self.speed = 0
msg.post("#sprite", "play_animation", { id = hash("explosion") })
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("animation_done") then
go.delete()
end
end
as the britzl pointed, the first time i did this i named the sprite rocket_sprite so it did the exact same behavior you described
edit: if not mistaken you named it rocket1