Skip to content

World2D ​

A UI node that shows the sprites and tile maps inside it through a camera, and answers 2D queries.

Inherits UiNode → Instance.

Made with Instance.new("World2D").

Properties ​

NameTypeNotes
CameraPositionVector2The world point shown at the centre, when there is no CameraSubject.
CameraSubjectSprite?A sprite the camera follows, or nil.
ZoomnumberScreen pixels to a world unit.

Methods ​

  • GetOverlapping(sprite: Sprite): {Instance}: What touches a sprite's hitbox.
  • GetSpritesAt(position: Vector2): {Sprite}: The visible sprites drawn at a point, topmost first.
  • Move(sprite: Sprite, delta: Vector2): Vector2: Moves a sprite, stopping at what it collides with, and returns how far it went.
  • Overlap(center: Vector2, size: Vector2, ignore: {Instance}?): {Instance}: The sprites and tile maps touching a box.
  • Raycast(origin: Vector2, direction: Vector2, ignore: {Instance}?): {Instance: Instance, Position: Vector2, Normal: Vector2, Distance: number, Cell: Vector2?}?: The first hitbox or solid tile along a direction, or nil.
  • ScreenToWorld(position: Vector2): Vector2: The world point drawn at a point of the surface.
  • WorldToScreen(position: Vector2): Vector2: Where a world point is drawn, in the surface's pixels.

Inherited ​

From UiNode: AddClass, AlignContent, AlignItems, AlignSelf, Animation, AnimationEnded, AspectRatio, Background, Blur, Blurred, BorderBottomLeftRadius, BorderBottomRightRadius, BorderBottomWidth, BorderColor, BorderLeftWidth, BorderRadius, BorderRightWidth, BorderTopLeftRadius, BorderTopRightRadius, BorderTopWidth, BorderWidth, Bottom, BoxShadow, CapturePointer, Classes, Click, ClickCapture, Color, ColumnGap, ContextMenu, Display, DoubleClick, DoubleClickCapture, DragEnd, DragEnter, DragLeave, DragOver, DragStart, Draggable, Drop, FlexBasis, FlexDirection, FlexGrow, FlexShrink, FlexWrap, Focus, Focused, FontFamily, FontSize, FontWeight, Gap, GridAutoColumns, GridAutoRows, GridColumn, GridRow, GridTemplateColumns, GridTemplateRows, HasClass, HasPointerCapture, Height, Id, Inset, IsDragOver, IsDragging, IsFocused, IsHovered, IsPressed, IsTransitioning, JustifyContent, KeyDown, KeyDownCapture, KeyUp, KeyUpCapture, LayoutChanged, LayoutRect, Left, LineHeight, Margin, MarginBottom, MarginLeft, MarginRight, MarginTop, MaxHeight, MaxWidth, MinHeight, MinWidth, Opacity, Overflow, Padding, PaddingBottom, PaddingLeft, PaddingRight, PaddingTop, PointerDown, PointerDownCapture, PointerEnter, PointerEvents, PointerLeave, PointerMove, PointerMoveCapture, PointerUp, PointerUpCapture, Position, ReleasePointerCapture, RemoveClass, Right, RowGap, ScrollIntoView, ScrollPosition, ScrollSize, TabIndex, TextAlign, TextOverflow, ToggleClass, Top, Transform, TransformOrigin, Transition, TransitionEnded, UserSelect, Wheel, WheelCapture, WhiteSpace, Width, ZIndex.

From Instance: AddTag, AncestryChanged, Archivable, AttributeChanged, Changed, ChildAdded, ChildRemoved, ClassName, ClearAllChildren, Clone, DescendantAdded, DescendantRemoving, Destroy, Destroying, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, GetDescendants, GetFullName, GetPropertyChangedSignal, GetTags, HasTag, IsA, IsAncestorOf, IsDescendantOf, IsPropertyModified, Name, Parent, QueryDescendants, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild.

Apache License 2.0