article thumbnail

Collision detection & Collision ignore

Cocos

Go to Project Settings → Physics → Collision Matrix There, you can create groups and assign which group interact/ignore with which group. Just my two cents and enjoy coding! Just my two cents and enjoy coding! Then, in your node’s collider, assign the desired group for it.

article thumbnail

Physics Collision with non dynamic types

Cocos

I’ve tried changing the type (static/kinematic/animated) of the other objects, but collision detection still doesn’t work. The only time collision is detected is when I set the “Character” object’s Rigidbody2D type to “dynamic”. This is the line of code I’m using to move the Character. const movement = new Vec2(x,y).normalize().multiplyScalar(this.speed);

Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Trending Sources

article thumbnail

Handle the collision of sprites

Cocos

I’m trying to handle the collision of two sprites, i added BoxCollider2D to the sprites. code for the "character ". code for the “key”. code for the "character ". code for the “key”. code for the "character ". code for the “key”. start () {. this.collider.on(Contact2DType.BEGIN_CONTACT, destroyKey(){.

Sprite 40
article thumbnail

Handle the collision of sprites

Cocos

best way to debug this kind of bugs is to activate physic debugging, add this to your code. onLoad() { PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb | EPhysics2DDrawFlags.Pair | EPhysics2DDrawFlags.CenterOfMass | EPhysics2DDrawFlags.Joint | EPhysics2DDrawFlags.Shape; }

article thumbnail

Collision3D event.contacts[] sometimes empty onCollisionEnter?

Cocos

and trying to find out the contactPoint when 2 colliders collide The docs said that I can get the collision’s event.contacts to get contactPoints, but my test code sometimes return an epty array of contactPoint for “onCollisionEnter” Is this a bug or I need to try “onCollisionStay” (which occurs repeatedly) ? Hi, I’m using Creator 3.8.2

article thumbnail

Module 3: Attack of the Snake (Lesson 10)

Game Designing

And the way to do that is by altering the collision mask on our block. Now, we haven’t talked about collision masks yet, so let’s do a quick overview of them and we’re going to dive way deeper into them in the next module where we make our space game. You can come in here and you can change the collision mask.

article thumbnail

UITransform.hitTest is not working correctly

Cocos

Basically, I have this code: register event this.node.on(NodeEventType.TOUCH_END, Hello, I’m using cocos creator 3.7.0, but method hitTest of UITransform is seem not working. NodeEventType.TOUCH_END, this._onTouchEnded, _onTouchEnded, this, true); process touch end: protected _onTouchEnded (event: EventTouch, captureListeners?: