function init(self)
msg.post(".", "acquire_input_focus")
self.vel = vmath.vector3()
end
function update(self, dt)
local pos = go.get_position()
pos = pos + self.vel * dt
go.set_position(pos)
self.vel.x = 0
self.vel.y = 0
self.vel = vmath.vector3(0,-10,0)
end
function on_message(self, message_id, message, sender)
-- Handle collision
if message_id == hash("contact_point_response") then
local newpos = go.get_position() + message.normal * message.distance
go.set_position(newpos)
end
end
function on_input(self, action_id, action)
if action_id == hash("up") then
self.vel.y = 80
elseif action_id == hash("down") then
self.vel.y = -80
elseif action_id == hash("left") then
self.vel.x = -80
elseif action_id == hash("right") then
self.vel.x = 80
end
end
This code seems to work but.
The players seems to stick to the walls as well as the floor and cant seem to get away from them.
I tried to apply the projection physics code to rectify this issue but got an error
ERROR:SCRIPT: main/Script/test.script:26: bad argument #1 to âprojectâ (vector3 expected, got nil)