Krotox Engine › Docs › Krotox Manual › 2D Content

2D component reference

Every 2D component you can add in the inspector, with its fields and defaults: transforms and sorting, sprites and animation, shapes, lines, trails, text, particles, masks, sprite effects, 2D lights, parallax, cameras and audio.

Components are added from Add Component in the Properties panel (the 2D tab lists the 2D ones). This page lists what each one does and what its fields mean. Physics components have their own page: 2D physics. Scripting access is covered in Sprites, animation, cameras & effects API.

Transform

Every entity has one.

FieldDefaultMeaning
Translation0, 0, 0Position, relative to the parent. In 2D, X is right and Y is up.
Rotation0, 0, 0Euler angles in radians. 2D rotation is around Z. The inspector shows degrees.
Scale1, 1, 1Size multiplier. Also scales colliders.

For a child entity, the inspector also shows its read-only world position, rotation and scale.

Draw order: sorting layers

Every 2D renderer (sprites, animated sprites, shapes, circles, lines, trails, text, masks) has two sorting fields:

Use layers for broad groups and Order in Layer for fine control inside a group.

Sprite Renderer

Draws a texture (or one cell of a sprite sheet) on a quad.

FieldDefaultMeaning
ColorwhiteTint multiplied with the texture. Alpha below 1 makes it see-through.
TexturenoneThe image. Drag one from the Content Browser. With none, it draws a solid colour quad.
Tiling Factor1, 1Repeats the texture across the quad.
Use Sub TextureoffDraw one cell of a sprite sheet instead of the whole image.
Sub Texture Coords0, 0Which cell (column, row).
Cell Size16, 16Size of one cell in pixels.
Sprite Size1, 1How many cells the sprite spans.
Gap Size0, 0Pixel spacing between cells on the sheet.
Flip X / Flip YoffMirror the image. Handy for turning a character around.
Pivot0.5, 0.5The point the sprite rotates and scales around.
Draw ModeSimpleSimple stretches the image. Sliced keeps the corners at their size and stretches the middle (nine-slice), using Slice Border.
Pixels Per Unit100How many texture pixels make one world unit.
Normal MapnoneOptional normal map, so 2D lights shade the sprite.
Mask InteractionNoneVisible Inside Mask or Visible Outside Mask to be clipped by a Sprite Mask.

Animated Sprite

Plays frames from a sprite sheet (or a list of separate images).

FieldDefaultMeaning
Sprite SheetnoneThe sheet the frames come from.
Cell Size / Sprite Size / Gap Size16, 16 / 1, 1 / 0, 0Same as the Sprite Renderer's sub-texture fields.
FramesemptyThe ordered list of cells to play.
Use Individual TexturesoffPlay a list of separate images instead of sheet cells.
Frame Duration0.1 sHow long each frame shows. 0.05 is 20 frames per second.
Is Playing / Loopon / onPlayback state; loop back to the first frame at the end.
Flip X / Flip Y, Pivotoff, 0.5, 0.5As on the Sprite Renderer.
Use State MachineoffUse named states (such as *Idle*, *Run*, *Jump*), each with its own frames.
States, Default State—The states, and which one starts.

With the state machine on, scripts switch animations with SetAnimationState("Run"). For timelines and parameter-driven transitions, use the Animator with the State Machine panel instead.

Circle Renderer

A circle or ring drawn with smooth, anti-aliased edges.

FieldDefaultMeaning
ColorwhiteTint.
Radius0.5Radius in world units.
Thickness11 is a filled disc; smaller values make a ring.
Fade0.005Edge softness. Raise it for glows and soft vignettes.
TexturenoneOptional texture inside the circle (sub-textures supported).

Shape Renderer

Regular shapes without a texture: Triangle, Diamond, Pentagon, Hexagon, Octagon and Star.

FieldDefaultMeaning
TypeHexagonWhich shape.
Sides6Side count for polygons.
Inner Radius0.45Inner radius (the depth of a star's points).
Thickness11 is filled; smaller values give an outline.
Fade0Edge softness.

Line Renderer 2D

A polyline of one width and colour, for ropes, bowstrings, lasers and trajectory previews.

FieldDefaultMeaning
Points(-0.5, 0), (0.5, 0)The points, edited as a list with *Add Point* and remove buttons.
Width0.05Width in world units, whatever the entity's scale. Corners are mitred, and bevelled when sharper than about 29°.
Color, Loopwhite, offColour; join the last point back to the first.
Use World SpaceoffOff: points move with the entity. On: points are world positions.

Trail Renderer 2D

Leaves a fading ribbon behind a moving entity: sword swings, dashes, projectiles.

FieldDefaultMeaning
Time1 sHow long a point stays in the trail.
Min Vertex Distance0.1How far the entity must move before a new point is added.
Start Width / End Width0.2 / 0Width at the head and the tail.
Start Color / End Color—Colour along the trail, usually fading to transparent.
EmittingonTurn off to stop adding points (the trail fades out).
TexturenoneOptional texture along the ribbon.

Text (world text)

Text that lives in the world, rendered with multi-channel signed distance fields so it stays sharp at any zoom. For menus and HUDs, use UI Text on a canvas instead (see Game UI).

FieldDefaultMeaning
Text—The string (UTF-8).
Font FamilyMontserratWhich font.
Color, Font Sizewhite, 1Colour and size multiplier.
Kerning, Line Spacing0, 0Extra space between characters and between lines.
Bold, ItalicoffUses real bold and italic font files when the font has them.
Drop Shadow (colour, distance, softness)offA shadow pass under the text.
Outline (colour, width)0A stroke around each glyph.
Alignment, Vertical AlignmentCenter, CenterHorizontal and vertical alignment.
Word Wrap, Wrap Widthoff, 10Break lines at word boundaries before this width (world units).

Particle System

Emits many small sprites for sparks, smoke, dust, rain and explosions.

FieldDefaultMeaning
TexturenoneParticle image; with none, plain coloured quads.
Is Emitting, Emission Rateon, 10Continuous emission, in particles per second.
BurstsnoneOne-off bursts of N particles at set times in the cycle.
Duration, Looping, Prewarm, Start Delay5 s, on, off, 0The emitter's cycle. Prewarm starts it as if it had already been running.
Play On AwakeonStart when the scene starts.
Start Speed5Initial speed of each particle.
Gravity Modifier0How strongly gravity pulls particles.
Simulation SpaceLocalLocal: particles move with the emitter. World: they stay where they were emitted.
Simulation Speed1Playback speed.
Shape, Shape Radius, Shape AnglePoint, 1, 25°Where particles start: Point, Circle, Cone, Box, Sphere, Hemisphere.
BlendingAlphaAlpha for smoke and dust, Additive for fire, sparks and glows.
Noise (strength, frequency, scroll speed)offTurbulence for drifting smoke and embers.
Collision (bounciness, friction, kill on collision)offLet particles bounce off the world.

Colour and size over lifetime are edited as curves in the inspector.

Sprite Mask

Shows or hides parts of other sprites, using its texture's shape. Sprites opt in through their Mask Interaction field.

FieldDefaultMeaning
Texture (+ sub-texture fields)noneThe mask shape.
Alpha Cutoff0.2Texture pixels more opaque than this count as inside the mask.
InvertoffSwap inside and outside.
Show Mask GraphicoffAlso draw the mask's own texture.
Custom RangeoffOnly affect sprites between a front and a back sorting position, instead of every sprite.

Sprite Effects 2D

Shader effects for Sprite Renderers and Animated Sprites on the same entity.

FieldDefaultMeaning
EnabledonTurn every effect off at once.
Flash Color, Flash Amountwhite, 0Tints the sprite toward a colour. Scripts call HitFlash(seconds) for a damage flash.
Outline, Outline Color, Outline Widthoff, white, 2 pxAn outline around the sprite's opaque pixels (width in screen pixels).
Dissolve Amount00 is whole, 1 is gone. Animate it to burn a sprite away.
Dissolve Edge Color, Edge Width, Noise Scaleorange, 0.08, 8The glowing edge and the grain of the dissolve.

Light 2D

Lights 2D scenes. Turn the scene's ambient light down (SceneManager.AmbientLight2D from scripts) and add lights to bring areas up.

FieldDefaultMeaning
TypePointPoint (radial), Spot (a cone) or Global (lights everything).
Color, Intensitywhite, 1Colour and brightness.
Inner Radius, Outer Radius0, 5Full brightness inside the inner radius, fading to zero at the outer.
Falloff1Shape of the fade.
Inner Angle, Outer Angle25°, 45°A spot light's cone.
Cast Shadows, Shadow Strength, Shadow Softnessoff, 0.8, 0Hard shadows from shadow-caster geometry. Softness is the light's size in world units; 0 is hard.

Turn on Scene ▸ Show Light 2D Ranges to see each light's reach in the Viewport. Sprites with a normal map are shaded per pixel.

Parallax Layer 2D

Moves a background layer slower or faster than the camera for depth.

FieldDefaultMeaning
Factor0.5, 00 is fixed to the camera (very far away), 1 moves with the world. Per axis.
Repeat0, 0Wrap the layer every this many units, for endless backgrounds. 0 disables wrapping.

Camera

Every scene needs one primary camera; the game is drawn through it.

FieldDefaultMeaning
ProjectionOrthographicOrthographic is what 2D games use.
Orthographic Size10How much of the world is visible vertically. Smaller is more zoomed in.
Near / Far Clip—Depth range.
Fixed Aspect RatiooffKeep the aspect ratio when the window resizes.
PersistentoffKeep this camera across scene loads.
Blend Time, Blend Target1 s, noneSmoothly blend toward another camera.

Camera Follow 2D

Makes the camera follow a target smoothly. Add it to the camera entity.

FieldDefaultMeaning
TargetnoneThe entity to follow (usually the player).
Offset0, 0Where the target sits relative to the centre of the view.
Damping0.15, 0.15Smoothing per axis. 0 snaps; larger values lag more.
Dead Zone0, 0An area in the middle where the target can move without the camera moving.
Look Ahead Time, Look Ahead Max0, 2Lead the camera in the direction the target is moving.
Use Bounds, Bounds Min, Bounds Maxoff, -10, 10Keep the view inside the level.
Pixel Snap, Pixels Per Unitoff, 16Snap the camera to whole pixels, for pixel art.

Camera Zone 2D

A region that changes how the follow camera behaves while its target is inside: lock the view to a room, zoom out for a boss arena, slow the follow in a cave.

FieldDefaultMeaning
Enabled, Priorityon, 0Overlapping zones resolve by priority.
Offset, Size0, 0, 20 × 12The zone's rectangle.
Blend Time0.5 sHow long the camera takes to adjust when the target enters or leaves.
Confine ViewonKeep the view inside the zone.
Override Damping, Override Dead Zone, Override Zoom (+ Orthographic Size)offReplace the follow camera's settings while inside.

Camera Shake 2D

Trauma-based screen shake: the more trauma, the stronger the shake, and trauma decays over time.

FieldDefaultMeaning
Max Offset0.5Largest positional shake, in world units.
Max Angle3°Largest rotational shake.
Frequency25How fast it shakes.
Trauma Decay1.5How quickly trauma fades, per second.

Audio Source

Plays a sound on an entity.

FieldDefaultMeaning
Audio Path—The file, relative to Assets: .wav, .mp3, .ogg or .flac.
GroupSFXMixer group: Master, Music, SFX, UI, Dialogue or Ambience.
Volume, Pitch, Pan1, 1, 0Loudness, speed, stereo position.
Volume Variation, Pitch Variation0, 0Random variation per play, so repeated sounds do not sound identical.
Loop, Play On Startoff, on
StreamoffStream from disk instead of decoding into memory. Use it for music.
Fade In / Fade Out Duration0, 0Fades when playing and stopping.
Priority128Which sounds survive when too many play at once.
Spatial, Min Distance, Max Distanceoff, 1, 100Fade with distance from the Audio Listener.

Put an Audio Listener on the camera (or the player) for spatial sounds. Group volumes are mixed in Window ▸ Audio Mixer.

Script

Runs one of your C# classes on the entity. Set the class name with its namespace (for example Sandbox.PlayerController), or drag a .cs file onto the entity. The script's public fields appear underneath. See Writing scripts & the lifecycle.