Need of help with upgrading BoxCollider to BoxCollider2D (upgrade cocos version from 2.x to 3.x)

Hello guys,

I’m current upgrading my project from version 2.x to 3.x and I don’t know how to get self.world.preAabb in version 3.x

Here example code in version 2.4:

onCollisionEnter: function (other, self) {
    console.log('on collision enter');

    // Collider Manager will calculate the value in world coordinate system, and put them into the world property
    var world = self.world;

    // Collider Component aabb bounding box
    var aabb = world.aabb;

    // The position of the aabb collision frame before the node collision
    var preAabb = world.preAabb;

},

I can get aabb like this in version 3.x :

var aabb = self.worldAABB

How can I get prevAabb in version 3.x ?

var prevAabb = ???

Thank you.

In Cocos Creator 2.x, you could directly access self.world.preAabb.
But in 3.x, the preAabb property was removed. You only have access to the current worldAABB.

If you need the previous AABB (the old preAabb), you’ll have to store it manually each frame.

Oh, I got it, thank you.