Entity

Reference for the base Entity class, which represents any object in the scene with transform, rendering, collision, input and scripting support.

Entity

Entity(add_to_scene_entities=True, enabled=True, **kwargs)

Located in ursina/entity.py

Overview

The Entity class is the foundation for all scene objects. It provides position, rotation, scale, rendering, collision, input routing and script management. You can parent it under scene for 3D or under camera.ui for UI space.

Constructor Arguments

ArgumentTypeDefaultDescription
add_to_scene_entitiesboolTrueIf False, it will not be tracked by the engine update loop, but still rendered.
enabledboolTrueIf False, the entity is invisible and its update/input methods are not run.
**kwargsanyAny other attribute (position, model, color, etc.) can be set via kwargs.

Attributes

NameDescription
rotation_directionsDefault axes inversion for .rotation.
nameAuto‑generated from class name in snake_case.
ignoreIf True, entity’s update/input code will not run.
ignore_pausedIf True, still runs when the application is paused.
ignore_inputIf True, input events are not sent to this entity.
parentParent entity (default scene). Set to camera.ui for UI space.
add_to_scene_entitiesSee constructor argument.
scriptsList of attached script instances.
animationsActive animations on this entity.
hoveredTrue when mouse is over the collider.
line_definitionTraceback info for where this entity was created.
enabledSee constructor argument.

Properties

PropertyDescription
.enabledGet/set enabled state.
.modelName of the model to render (without extension).
.colorTint color.
.eternalIf True, not destroyed on scene.clear().
.double_sidedIf True, render both faces of polygons.
.render_queueCustom draw order (use .z for simple 2D sorting).
.parentCurrent parent.
.loose_parentChange parent without affecting world transform.
.world_parentAlias for loose_parent.
.typesList of class names in its inheritance chain.
.visibleGet/set visibility including children.
.visible_selfGet/set visibility of this entity only.
.colliderCollider shape: 'box', 'sphere', 'capsule', 'mesh'.
.collisionToggle collision detection without changing collider.
.on_clickHandler called on mouse click.
.origin, .origin_x, .origin_y, .origin_zAnchor point for position and rotation.
.position, .x, .y, .zLocal position or individual axes.
.X, .Y, .ZInteger-cast shortcuts for .x, .y, .z.
.world_position, .world_x, .world_y, .world_zPosition in world space.
.rotation, .rotation_x, .rotation_y, .rotation_zLocal rotation or individual axes.
.world_rotation, .world_rotation_x, .world_rotation_y, .world_rotation_zRotation in world space.
.quaternionRotation as quaternion.
.scale, .scale_x, .scale_y, .scale_zLocal scale or individual axes.
.world_scale, .world_scale_x, .world_scale_y, .world_scale_zScale in world space.
.transformCombined (position, rotation, scale).
.world_transformCombined world transform.
.forward, .back, .right, .left, .up, .downDirection vectors in world space.
.screen_positionProjected UI‑space position.
.shaderAssigned shader.
.shader_inputShader input values.
.materialShortcut to set shader, texture, scale, offset and inputs together.
.textureTexture path (requires a model).
.texture_scaleUV tiling factor, e.g. (8,8).
.texture_offsetUV offset.
.tileset_sizeGrid size when using a tileset.
.tile_coordinateIndex of tile in a tileset.
.alphaShortcut for color transparency.
.always_on_topIf True, render on top of others.
.unlitIf True, ignore lighting.
.billboardIf True, face the camera always.
.wireframeIf True, draw as wireframe.
.model_bounds, .boundsMesh bounds information.
.flipped_facesIndicates inverted normals.
.children, .loose_childrenChild entities.
.attributesList of attribute names (used by duplicate()).

Methods

MethodDescription
enable()Equivalent to .enabled = True.
disable()Equivalent to .enabled = False.
get_shader_input(name)Return shader input value.
set_shader_input(name, value)Set shader input value.
generate_sphere_map(size=512, name=...)Create a spherical environment map texture.
generate_cube_map(size=512, name=...)Create a cube‑map environment texture.
get_position(relative_to=scene)Get position relative to another entity.
set_position(value, relative_to=scene)Set position relative to another entity.
rotate(value, relative_to=None)Rotate around local or given axis.
add_script(class_instance)Attach a script component.
combine(analyze=False, auto_destroy=True, ...)Merge child meshes into one mesh.
look_at(target, axis='forward', up=None)Orient entity to face a target in 3D.
look_at_2d(target, axis='z')Orient in 2D (ignoring one axis).
look_at_xy(target)Face a target in the XY plane.
look_at_xz(target)Face a target in the XZ plane.
has_ancestor(possible_ancestor)True if this entity is nested under another.
has_disabled_ancestor()True if any parent is disabled.
get_changes(target_class=None)Return dict of properties that differ from defaults.
animate(name, value, duration=.1, ...)Animate any attribute over time with optional curve, delay, looping.
animate_position(value, duration=.1, **kwargs)Shortcut to animate .position.
animate_rotation(value, duration=.1, **kwargs)Shortcut to animate .rotation.
animate_scale(value, duration=.1, **kwargs)Shortcut to animate .scale.
shake(duration=.2, magnitude=1, ...)Apply a shaking effect to a chosen attribute.
animate_color(value, duration=.1, ...)Animate .color.
fade_out(value=0, duration=.5, ...)Fade transparency to a target alpha.
fade_in(value=1, duration=.5, ...)Fade transparency back in.
blink(value=color.clear, duration=.1, ...)Quick fade‑out and back‑in (boomerang curve).
intersects(traverse_target=scene, ignore=None, debug=False)Return collision hits against a collider or scene.

Example Usage

from ursina import *
app = Ursina()

# simple quad entity
e = Entity(
    model='quad',
    color=color.orange,
    position=(0,0,1),
    scale=1.5,
    rotation=(0,0,45),
    texture='brick'
)

# subclassing Entity
class Player(Entity):
    def __init__(self, **kwargs):
        super().__init__()
        self.model = 'cube'
        self.color = color.red
        self.scale_y = 2
        for key, value in kwargs.items():
            setattr(self, key, value)

    def input(self, key):
        if key == 'space':
            self.animate_x(2, duration=1)

    def update(self):
        self.x += held_keys['d'] * time.dt * 10
        self.x -= held_keys['a'] * time.dt * 10

player = Player(x=-1)

app.run()