MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Raycasting 3D Render

Transforms your 2D tilemaps and sprites into a first-person 3D/2.5D raycasted world with jumping, heights, camera controls, and multi-directional animations.

run code when sprite dirction updated to

Problem it solves

You are using a custom character animation system and need to know which directional angle the player is currently viewing each enemy from.

What this block does

Runs a custom callback function whenever a sprite's relative viewpoint angle changes, providing a direction float from 0 to 1 representing 0° to 360°.

The block

Block ID: rcRender_registerOnSpriteDirectionUpdateHandler

run code when sprite $spr dirction updated to $dir block

Parameters

NameTypeDefaultMeaning
handler(spr: Sprite, dir: number) => voidCallback function receiving the sprite and its relative viewing angle (0 to 1).

Returns

void — Nothing.

Example

Render.registerOnSpriteDirectionUpdateHandler(function (spr, dir) {
    let dirIndex = Math.round(dir * 4) % 4
})

Add the extension

Add github:The-Code-Zone/Raycasting-pxt-extension to your project, or open: Import Raycasting-pxt-extension.