Daabbcc collision issue

There seems to be a collision problem if I change the size with daabbcc.update_gameobject_size.

If:

  1. the two colliding objects have approximately the same x-coordinate, i.e. they are almost vertically aligned (and only vertically, horizontally this problem is not apparent),
  2. they are very close
  3. as soon as the collision occurs, I change the size of one of the two objects by making it much smaller

then

the two objects collide in the next frame even though they should not.

I hope I have explained the problem clearly enough.

@roccosaienz If you tag me here on the forum, open an issue, or post a question in the discussions section on GitHub, I might be able to reply sooner since I get notifications.

It seems a bit tricky to reproduce this. I’d appreciate it if you could share a minimal repo case when you encounter the issue. It will save both of us some time.

I tried to reproduce this (as far as I understood) but couldn’t catch the issue:

  • Blue is moving on Y-axis
  • When it collides with pink, I set its size to 5x5. Since it gets smaller (and is no longer colliding), it will continue to move on the Y-axis and collide again.

code:

local group_id = daabbcc.new_group(daabbcc.UPDATE_FULLREBUILD)
local aabb1_id, aabb2_id
local y = 55

function init(self)
	aabb1_id = daabbcc.insert_gameobject(group_id, "/pink", 50, 20) -- static pink
	aabb2_id = daabbcc.insert_gameobject(group_id, "/blue", 50, 20) -- Moving blue rect
end

function update(self, dt)
	local result, count = daabbcc.query_id(group_id, aabb2_id)

	if result then
		print("Collision occurred - Set Size")
		daabbcc.update_gameobject_size(group_id, aabb2_id, 5, 5)

		-- Since it gets smaller, it will continue to move on the Y-axis and collide again
		go.set("/blue#sprite", "size", vmath.vector3(5, 5, 0))
		sprite.play_flipbook("/blue#sprite", hash("red"))
	else
		y = y - 0.1
		go.set_position(vmath.vector3(0, y, 0), "/blue") -- move blue
	end
end


4 Likes

It also worked as expected with go.animate, even at high speed. I guess I’m missing something…

local group_id = daabbcc.new_group(daabbcc.UPDATE_FULLREBUILD)
local aabb1_id, aabb2_id
local hit = false

function init(self)
	aabb1_id = daabbcc.insert_gameobject(group_id, "/pink", 50, 20) -- static pink
	aabb2_id = daabbcc.insert_gameobject(group_id, "/blue", 50, 20) -- Moving blue rect
	go.animate("/blue", "position.y", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_LINEAR, 0.1)
end

function update(self, dt)
	local result, count = daabbcc.query_id(group_id, aabb2_id)

	if result then
		if hit == false then
			hit = true
			print("Collision occurred - Set Size")
			daabbcc.update_gameobject_size(group_id, aabb2_id, 5, 5)
			-- Since it gets smaller, it will continue to move on the Y-axis and collide again

			go.set("/blue#sprite", "size", vmath.vector3(5, 5, 0))
			sprite.play_flipbook("/blue#sprite", hash("red"))
		else
			print("Collision occurred - For small red rect")
			go.cancel_animations("/blue", "position.y")
		end
	end
end
1 Like

I did not tag you on purpose. There is no rush for this issue. And I’m so glad I can use daabbcc in my game.

Thanks for the video and the test code. I will try to create a minimal project that reproduces the error; assuming I succeed and the problem is not somewhere else in my code.

Thank you again!

1 Like

@selimanac It seems to me that the attached project shows the issue. It is almost identical to your test code but I increase y.

Probably I am missing something very stupid… sorry.

Thanks!

defold_daabbcc_test.zip (3.0 KB)

This is not related to your example. I was testing with my local development version of daabbcc and realized that I forgot to push a very small but important fix related to width and height(size).
Your example works fine with my local version but not with the online 3.0.1 due to my mistake. Sorry about that.
Could you please check with main v3.x branch now. It should work, I’m going to prepare a release

2 Likes

@selimanac Thank you so much! I am sorry but I don’t understand your suggestion about testing with v3.x. What should I write in the Dependencies of game.project?

Thanks again!

1 Like

Can you change your dependencies URL, fetch again (Projects → Fetch Libraries) with this, and test it, please? This is the main branch for 3.x

https://github.com/selimanac/defold-daabbcc/archive/refs/heads/v3.x.zip
2 Likes

@selimanac Sorry for the delay in testing this. Yes, it works with v3.x!

Thank you so much!

2 Likes

Great, thank you for testing! I’ve released a new version

1 Like