I used the described collision handling with a kinetic player objekt and a static wall.
when a player hits the wall his vector is corrected. it works, yet i see bouncing, when the player hit a corner of a square or sometimes in general when you press (top and right) and strafe along the wall.
Does anyone know a solution where less bouncing (correction) is done?
video imgur
if message.distance > 0 then
if message_id == hash("contact_point_response") then
local proj = vmath.project(self.correction, message.normal * message.distance)
if proj < 1 then
-- Only care for projections that does not overshoot.
local comp = (message.distance - message.distance * proj) * message.normal
go.set_position(go.get_position() + comp)
-- Accumulate correction done
self.correction = self.correction + comp
end
end
player go (for settings of physics)
embedded_components {
id: "collisionobject"
type: "collisionobject"
data: "collision_shape: \"\"\n"
"type: COLLISION_OBJECT_TYPE_KINEMATIC\n"
"mass: 0.0\n"
"friction: 3.0\n"
"restitution: 3.0\n"
"group: \"player\"\n"
"mask: \"enemyshot\"\n"
"mask: \"nonwalkable\"\n"
"mask: \"coin\"\n"
"embedded_collision_shape {\n"
" shapes {\n"
" shape_type: TYPE_SPHERE\n"
" position {\n"
" x: 1.0\n"
" y: 22.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" index: 1\n"
" count: 1\n"
" }\n"
" data: 22.0\n"
" data: 22.0\n"
"}\n"
"linear_damping: 3.0\n"
"angular_damping: 3.0\n"
"locked_rotation: false\n"
""