Hi
I am currently trying to make a program in Defold however for some reason it isn’t letting my character move at all. I have used the same code in previous programs without issues so idk why it is happening now. The part of the code which the error is saying has the error is below.
Also with the character not moving it is also giving me the following error message when I load the levels. Any help for this will be appreciated.
function update(self, dt)
self.previous_pos = go.get_position()
self.pos = go.get_position()
-- means player can't go out of bounds
if self.pos.x < 0 then
self.pos.x = 0
end
if self.pos.y > 640 then
self.pos.y = 640
end
if self.pos.y < 0 then
self.pos.y = 0
self.direction.y = 0
self.jump = true
self.touch_floor = true
end
if not self.touch_floor then
self.direction = self.direction + vmath.vector3(0, -20, 0)
end
if self.direction.x > 0 and self.movement == false then
self.next_animation = hash("chara_right_still")
elseif self.direction.x < 0 and self.movement == false then
self.next_animation = hash("chara_left_still")
end
go.set_position(self.pos * self.direction * dt * speed)
if self.next_animation ~= self.current_animation then
msg.post("#sprite", "play_animation", {id = self.next_animation})
self.current_animation = self.next_animation
end
self.direction.x = 0
self.correction = vmath.vector3()
self.touch_floor = false
end