How to Use Sprite Origins in GameMaker

What are Sprite Origins?

A sprite’s origin is the point that corresponds to it’s position in the room. By default, the origin is in the top-left corner of the sprite, but moving it may make a difference to your game.

How to Set a Sprite Origin

When you preview a sprite asset, you’ll see the origin represented by a semi-transparent crosshair. There’s a few options to change its position.

Option 1: Click and drag it around the sprite to reposition the sprite’s origin.

Option 2: Enter the x and y values of the sprite’s origin using the input fields in the upper-right of the sprite preview window.

Option 3: Select a fixed position from the dropdown in the upper-right. These are common places for a sprite origin to be.

Why Sprite Origin Placement Matters

Your sprites will behave differently during gameplay depending on the origin of the sprite.

Rotation

The origins here are drawn as a red point. The sprite will rotate around the origin using image_angle.

Scaling

The origins here are drawn as a red point. The sprite will scale away from the origin when using image_xscale and image_yscale.

Place the sprite origin where it makes the most sense for the sprite’s rotation and scale! If a sprite spins in mid-air, you may want the origin to be in the center. If a sprite is able to grow bigger while standing on a platform, you probably want the origin to be at the bottom-center, near the character’s feet.

Sprite Origin in GML

You can use sprite_set_offset(ind, xoff, yoff) to change the origin of a sprite in GML while the game is running.

This will change the sprite origin for the sprite asset itself, so any object using the sprite will see the change!

Wrap Up

Setting a sprite’s origin gives you control over how a sprite is drawn to the screen. It also gives you control over how a sprite rotates and scales! There’s no one right origin for all of your sprite, so think about its in-game behavior to decide on the right place for your sprites.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top