You are setting the self.curAnim variable twice. First you set it to “run” and immediately afterwards to “idle”. You should remove the line where you set it to “idle”
But you’ve changed the entire update() function from when you last posted here! You should remove only one line!
This is what it is supposed to look at (I haven’t tested it though):
function init(self)
msg.post(".","acquire_input_focus")
self.runSpeed = 50
self.curAnim = "idle"
msg.post("#sprite", "play_animation", { id=hash("idle") })
self.speed = vmath.vector3()
particlefx.play("#playerparticle")
end
function update(self, dt)
local pos = go.get_position()
if self.speed.x ~= 0 then
pos = pos + self.speed * dt
go.set_position(pos)
if self.curAnim ~= "run" then
msg.post("#sprite", "play_animation", { id=hash("run") })
self.curAnim = "run"
end
elseif self.curAnim ~= "idle" then
msg.post("#sprite", "play_animation", { id=hash("idle") })
self.curAnim = "idle"
end
self.speed = vmath.vector3()
end
function on_input(self, action_id, action)
if action_id == hash("MOVE_RIGHT") then
self.speed.x = self.runSpeed
sprite.set_hflip("#sprite", false)
end
if action_id == hash("MOVE_LEFT") then
self.speed.x = self.runSpeed * -1
sprite.set_hflip("#sprite", true)
end
end
Have you tried anything of your own to solve this? Have you restarted Defold? Have you tried a different project? Check your task manager if there’s a dmengine.exe still running, and if so shut it down. Have you restarted your computer?
Now my dynamic physics object is going flying. I have a static object on at the bottom (not near the dynamic one). I have tried changing the mass and all the physics settings in the object and game.project.
No idea really. I suggest that you strip your project down to a bare minimum first and compare to what you have now. A dynamic collision object will interact with the static one and bounce around. How much depends on gravity (in game.project) and restitution (on collision objects). Here’s a small example of two dynamic objects colliding with some static objects and each other: