is sprites overlaps in Z dimension
Problem it solves
A flying bat and a low fireball collide in 2D top-down coordinates, but the bat is flying high above the fireball and should not take damage.
What this block does
Checks if two sprites overlap in vertical height (the Z-axis). Works best inside regular sprite overlap events to make collisions 3D-aware.
The block
Block ID: rcRender_isSpritesOverlapZ
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite1 | Sprite | mySprite | First sprite to check. |
| sprite2 | Sprite | mySprite2 | Second sprite to check. |
Returns
boolean — true if the sprites overlap along the vertical Z dimension.
Example
sprites.onOverlap(SpriteKind.Enemy, SpriteKind.Projectile, function (enemy, proj) {
if (Render.isSpritesOverlapZ(enemy, proj)) {
proj.destroy()
enemy.destroy()
}
})Add the extension
Add github:The-Code-Zone/Raycasting-pxt-extension to your project, or open: Import Raycasting-pxt-extension.