I wish you guys had a discord or something, hate to take up space with what’s probably such a simple question
New to Defold, so I’m sure there’s some rule that I’m not aware of causing this (or my math is just wrong). I’m trying to move the player towards wherever I click.
In main.script I have this:
if(action_id == hash("touch")) then msg.post("/player#player", "move", {vmath.vector3(action.x, action.y, 0)}) end
and in the player.script I have this
function on_message(self, message_id, message, sender)
if message_id == hash(“move”) then
print(“move received”)
pos = go.get_position()
moveto = vmath.normalize(message[1] - pos)
go.set_position(pos + moveto)
end
end
But when I click on the screen, the player only moves up and to the right- if I click different places he’ll move more to the right than up but always only northeast. What am I doing wrong?