I have a character gameobject moving left (kinematic), the character walks across static ground gameobjects using contact point response to stop them falling through.
However, when the character reaches the edge of one ground gameobject it always stops walking for a second?
The ground objects line up perfectly, and I tried making them overlapping but the character still stops!
Perhaps the corners of the of the collision shapes are sideways?
Take a look at two examples:
In the second example I simply moved the left hand ground piece upwards in the editor before building.
Here’s the code I’ve got on the character:
local group_geometry = hash("geometry")
local msg_contact_point_response = hash("contact_point_response")
function init(self)
self.gravity = -10
self.ground_contact = false
self.direction = "right"
self.correction = vmath.vector3()
end
function update(self, dt)
local currentpos = go.get_position()
if self.ground_contact == false then
newpos = currentpos + vmath.vector3(0,self.gravity,0)
end
if self.ground_contact == true and self.direction == "right" then
newpos = currentpos + vmath.vector3(1,0,0)
end
if self.ground_contact == true and self.direction == "left" then
newpos = currentpos + vmath.vector3(-1,0,0)
end
go.set_position(newpos)
self.correction = vmath.vector3()
self.ground_contact = false
end
local function handle_geometry_contact(self, normal, distance)
local proj = vmath.dot(self.correction, normal)
local comp = (distance - proj) * normal
self.correction = self.correction + comp
go.set_position(go.get_position() + comp)
self.ground_contact = true
end
function on_message(self, message_id, message, sender)
if message_id == msg_contact_point_response then
if message.group == group_geometry then
handle_geometry_contact(self, message.normal, message.distance)
end
end
if message_id == hash("collision_response")then
if message.group == hash("wall") then
if self.direction == "left" then
self.direction = "right"
else
self.direction = "left"
end
end
end
end
Yes, please turn on physics debug either by checking the box in game.project or by posting a message like @jcash showed in a previous reply. Post some screenshots or a gif when reproducing the issue with physics debug enabled.