War Battles tutorial explosion issue (SOVLED)

Hi, I was working through the War Battles tutorial and I reached the explosion of the rockets part, im gonna put exactly what´s the issue.

go.property("dir", vmath.vector3())                 -- [1]

function init(self)
	self.speed = 200                                -- [2]

end

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                              -- [1]
	if self.life < 0 then                                   -- [2]
		self.life = 1000                                    -- [3]
		go.set_rotation(vmath.quat())                       -- [4]
		self.speed = 0                                      -- [5]
		msg.post("#sprite", "play_animation", { id = hash("explosion") }) -- [6]
	end
end

function on_message(self, message_id, message, sender)      -- [1]
	if message_id == hash("animation_done") then            -- [2]
		go.delete()                                         -- [3]
	end 
end

ERROR:SCRIPT: /main/rocket.script:13: attempt to perform arithmetic on field ‘life’ (a nil value)
stack traceback:
/main/rocket.script:13: in function </main/rocket.script:8>

1 Like

forget it, I just need to initialize the variable

2 Likes