There seems to be a collision problem if I change the size with daabbcc.update_gameobject_size.
If:
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),
they are very close
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
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
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.
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
@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?