How to Make Sans’s Battle from Undertale in Scratch ep.4

How to Make Sans’s Battle from Undertale in Scratch ep.4
ok-scratch
In the last article, we completed Sans’s iconic Gaster Blaster. Now, let's enhance the bone attacks by creating a pattern where bones come from both sides, challenging players to dodge with the blue Soul under gravity.
Starter
Projects
Starter Project
Sample
none
Difficulty
Tags

Make sure to jot down the URL of your Scratch project in progress. It’s a lifesaver when you’re ready to dive back in.

LOADING...

This record is saved on the computer you’re currently using. So, if you switch to a different computer, you won’t see it there.

Since we completed the Gaster Blaster in the last article, let’s take the bone attacks to the next level! This time, we’ll create a challenging pattern where bones come from both sides, and you’ll need to dodge them using the blue Soul under gravity. Let’s dive in and make it happen!

Sprite 'Admin'

First, let’s adjust the timing for calling the new attack pattern in the Admin.

Message 'Attack 3'

Place the block so it runs right after the Gaster Blaster attack.

Sprite 'Attack 3'

Open the sprite named 'Attack 3'.

This sprite has a costume with bones lined up symmetrically, top and bottom. We’re going to make these bones attack the player from both sides simultaneously.

Since we’ll be using clones, let’s hide the main sprite when the green flag is clicked.

When I receive "Attack 3," set GRAVITY to 1, which changes the Soul color to blue.

Variable 'dir'

Create a new variable named "dir" for this sprite only, which represents the direction of the bones' movement.

Set "dir" to 1, meaning right to left.

Block Definition '_Attack'

Create a new block definition named '_Attack' that runs without screen refresh.

Place this block directly below.

Variables 'bone X', 'bone Y' and 'bones'

Create 3 new variables all for this sprite only.

Initialize these blocks as shown below.

Place the repeat block Place a repeat block set to 15 repetitions.

Create clone of myself inside.

Change 'bones' by 1.

Change 'bone X' by '100 * dir'.

ok-scratch ok-scratch

This way, each clone will be spaced 100 units to the right (or left). But remember, these are just variable values for now, so it won’t actually change the X position on the screen yet. We’ll set the real X positions in the next step. Just think of "bone X" as a pretend position for now.

Clone

Let’s code the movement for the clones. Place blocks as shown below.

Place an "if" block with a "greater than" block in its condition.

Insert the expression '100 > abs of bone X' into the condition.

ok-scratch ok-scratch

At the end of this forever block, we’ll be changing bone X by 4.5 each time. So, by displaying this clone when the absolute value of bone X reaches 100, it’ll be drawn perfectly within the frame.

Set X to 'bone X' and Y to 'bone Y'. Simple!

Then go to back layer and show.

ok-scratch ok-scratch

The reason we move it to the back layer is so that it stays hidden behind the "Base" sprite, preventing the bones from appearing outside the frame.

Place an "if" block with a "greater than" block in its condition again.

Insert the expression '-100 > ( bone X * dir )' into the condition.

Since -100 means the clone is out of the frame, delete the clone at this point.

At the end of the forever loop, change 'bone X' block.

Make an expression shown as below.

This is the complete expression: 0 - (4.5 * dir).

Insert this expression into the value.

ok-scratch ok-scratch

This makes it move 4.5 units to the left (or right).

Preview

Click the event block to test quickly.

Great! Now the bones are moving right to left.

ok-scratch ok-scratch

The reason the Soul isn’t affected by gravity is that we just clicked the event block for a quick test. If you test by clicking the green flag, you should see it affected by gravity properly.

Left to Right

Creating bones that move in the opposite direction is super easy—just set 'dir' to -1!

Preview

Cool! You can really see the bones attacking the player from both sides now!

Closing

The foundation for the Undertale Sans battle is finally complete! Let’s preview the finished project.

Woohoo! It’s awesome! Now it’s your turn—customize it to create your very own Sans battle. Adding dialogue and choices can get tricky, so start by creating more of your favorite battle patterns. Have fun and make it epic!

Thank you for reading! Thank you for reading!
Bookmark and share this article, if you like.

Scratch Games

    • You can find popular scratch projects with reviews.