LogoLogo
  • Get Started
  • Getting Started
    • Initial Setup
    • Create Your First Game
    • API Reference
    • Build Your First World Map
    • Multiplayer Testing
    • Use Templates & Examples
    • Styling & Assets
      • Modeling Guidelines
      • Texturing Guidelines
      • Default Assets
  • Build Faster With AI Tools
  • SDK Guides
    • Assets
    • Audio & SFX
      • Audio Manager
    • Blocks & Chunks
      • Block Types
      • Block Type Registry
      • Chunks
      • Chunk Lattice
    • Camera
    • Chat & Commands
    • Debugging
    • Entities
      • Animations
      • Block Entities
      • Colliders & Hitbox
      • Child Entities
      • Entity Controllers
        • Base Entity Controller
        • Pathfinding Entity Controller
        • DefaultPlayer Entity Controller
        • Simple Entity Controller
      • Entity Manager
      • Model Entities
      • Movement & Pathfinding
      • Player Controlled Entities
    • Events
    • Input & Controls
    • Lighting
      • Ambient Light
      • Light Manager
      • Point Lights
      • Spot Lights
      • Sun Light (Directional)
    • Mobile
    • Persisted Data
    • Players
      • Player Manager
      • Persisted Player Data
    • Plugins
    • Physics
      • Colliders
      • Collision Groups
      • Debugging
      • Gravity
      • Raycasts
      • Rigid Bodies
    • User Interface
      • Overlay UI
      • Scene UIs
      • Scene UI Manager
    • Worlds
      • Map Data Format
  • Helpful Resources
    • HYTOPIA Architecture & Platform Overview
    • Useful Third-Party Tools
Powered by GitBook
On this page
  • Creating A Point Light
  • Point Light Entity Attachment
  • Diving Deeper
Export as PDF
  1. SDK Guides
  2. Lighting

Point Lights

PreviousLight ManagerNextSpot Lights

Last updated 4 months ago

Points lights emit light of a specific color and intensity from a positional point in the world.

Point lights are real time lighting, meaning they will cast shadows and recalculate light each frame based on the objects in proximity of the light. This also means that point lights come at a much performance cost than ambient and directional lighting. Use point lights sparingly.

Creating A Point Light

const light = new Light({
  color: { r: 255, g: 0, b: 0 }, // the lights color, defaults to 255,255,255
  intensity: 5, // the lights intensity, defaults to 1
  position: { x: 10, y: 20, z: -10 } // where the point light emits in the world 
});

light.spawn(world);

Point Light Entity Attachment

You can attach a point light to follow an entity as the entity moves throughout the world like this.

const light = new Light({
  attachedToEntity: playerEntity, // the entity to follow
  color: { r: 255, g: 0, b: 0 },
  intensity: 5,
  offset: { x: 0, y: 1, z: 0 }, // an offset of the pointlight relative to the attached entity
});

light.spawn(world);

Diving Deeper

Point lights are created as a instance. The pattern of point light usage is similar to entities. You must create an instance of a Light first, then spawn the light in the world. Here's how we can do that.

The Light class, which is used to create point lights, supports a wide variety of features and is constantly evolving. If you'd like to learn more, we recommend you dig into the .

If there are features that we don't currently support for point lights that you'd like to see added to the HYTOPIA SDK, you can .

Light
Light API Reference here
submit a feature request here
A basic point light attached to our player's entity, emitting light around the player as they move.