Player stucks in wall

I am having some trouble with collisions, when player collides with wall object, player stucks on it

this is players code

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
end

function on_input(self, action_id, action)
	if action_id == hash("up") then
		self.vel.y = 150 -- <7>
	elseif action_id == hash("down") then
		self.vel.y = -150
	elseif action_id == hash("left") then
		self.vel.x = -150 -- <8>
	elseif action_id == hash("right") then
		self.vel.x = 150
	end
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

Can you guys help me

1 Like

change + to -

function on_message(self, message_id, message, sender)
	-- Handle collision
	if message_id == hash("contact_point_response") then
        -- change + to -
		local newpos = go.get_position() - message.normal * message.distance
		go.set_position(newpos)
	end
end