The RMLUI sprite management API allows you to render images at specific 3D world positions or screen positions using RMLUI. Sprites automatically scale based on their distance from the local player and can handle occlusion (blocking) and touch events.
Key Features:
- Automatic Scaling: Images scale down as the player moves away, based on a
DEFAULT_DRAW_DISTANCE of 20 units. - Occlusion Handling: Sprites become semi-transparent (
opacity: 0.1) if an entity is blocking the line of sight between the player and the sprite. - Touch Events: You can register a
callOnceOnTouch callback that triggers when the player is within a TOUCH_DISTANCE of 2 units. - Plugin Pathing: Supports a shorthand for plugin assets using the
@plugin/ prefix.
import { create, update, remove } from './path-to-this-module';
// Example: Creating a sprite
create({
uid: 'my-unique-sprite',
path: '@plugin/my-plugin/client/icon.png',
width: 64,
height: 64,
position: { x: 100, y: 200, z: 50 },
callOnceOnTouch: (uid) => {
console.log(`Sprite ${uid} was touched!`);
}
});