No more bouncing camera? (SOLVED)

I’m having an issue after changing the way my game’s physics works from drawn over long rectangles to now tile box based collision groups. This video shows what’s wrong

https://youtu.be/Mr2LJCOb8U0

This is my tile source:

this is the tile map game object:

this is the player’s code for walking

function update(self, dt) 
	local pos = go.get_position()
	self.speed = 460
	if input.is_pressed("move_left") and input.is_pressed("move_down") then
		self.speed = 315
		self.oldPos = pos
		pos.x = pos.x - (self.speed * dt)
		pos.y = pos.y - (self.speed * dt)
		self.moving = true
		go.set_position(pos)
	elseif input.is_pressed("move_left") and input.is_pressed("move_up") then
		self.speed = 315
		self.oldPos = pos
		pos.x = pos.x - (self.speed * dt)
		pos.y = pos.y + (self.speed * dt)
		self.moving = true
		go.set_position(pos)
	elseif input.is_pressed("move_right") and input.is_pressed("move_down") then
		self.speed = 315
		self.oldPos = pos
		pos.x = pos.x + (self.speed * dt)
		pos.y = pos.y - (self.speed * dt)
		self.moving = true
		go.set_position(pos)
	elseif input.is_pressed("move_right") and input.is_pressed("move_up") then
		self.speed = 315
		self.oldPos = pos
		pos.x = pos.x + (self.speed * dt)
		pos.y = pos.y + (self.speed * dt)
		self.moving = true
		go.set_position(pos)
	elseif input.is_pressed("move_right") and input.is_pressed("move_left") then
	elseif input.is_pressed("move_down") and input.is_pressed("move_up") then
	elseif input.is_pressed("move_left") then
		self.oldPos = pos
        pos.x = pos.x - (self.speed * dt)  
        go.set_position(pos)
        self.moving = true
        go.set_position(pos)
    elseif input.is_pressed("move_right") then
    	self.oldPos = pos
    	pos.x = pos.x + (self.speed * dt)
    	self.moving = true
    	go.set_position(pos)
    elseif input.is_pressed("move_up") then
    	self.oldPos = pos
    	pos.y = pos.y + (self.speed * dt)
    	self.moving = true
    	go.set_position(pos)
    elseif input.is_pressed("move_down") then
    	self.oldPos = pos
    	pos.y = pos.y - (self.speed * dt)
    	self.moving = true
    	go.set_position(pos)
    else
    	self.moving = false
    end 
    update_facing(self)
    update_animation(self) 
end

function update_facing(self)
	local table = {["pos"] = go.get_position(), ["facing"] = self.facing }
	msg.post("/blue stone", hash("update_position"), table)
end

This is the player’s code for handling a collision:

function on_message(self, message_id, message, sender)
	-- Wait for a message from the UI layer that the UI has been dismissed
	-- un-dim our sprite
    if(message_id == hash("DONE_UI")) then
    	go.set("#sprite","tint.w",1.0)
    	msg.post(".","acquire_input_focus")
	elseif(message_id == hash("contact_point_response")) then
		go.set_position(go.get_position() + (message.normal * message.distance))
    elseif(message_id == hash("animation_done")) then
    	self.animating = false
    elseif(message_id == hash("polo")) then
    	pprint(message)
    end
end

I just can’t seem to figure it out

What kind of collision shape are you using? Are you getting more than one contact_point_response per frame? Perhaps you need to use the same approach as in the infinite runner tutorial where you have a correction vector3?

1 Like

I’m pretty sure you’re right in that it’s just hitting multiple contact points at once. The way the editor is setting up the collisions is individual squares for each wall tile. I’ll just go back and undo the thing that was causing me those weird system errors and use a sprite instead of drawing a tile to show the tile in front of the player.

unrelated: Thank you for all the work you’ve done on these forums, you’ve already helped me tons!

1 Like

Yes, this is probably very likely and that will result in a separation that is too great which will cause the jitter/bounce that you’re seeing. If you accumulate and take into account multiple corrections during the frame the bounce will be prevented. See Resolving Kinematic Collisions in the Physics Documentation for details.

2 Likes

worked like a charm! thank you!