Soft Body’s Movement

Zeke Virant
3 min readJun 16, 2016

--

Here’s a short thing on how I designed Soft Body’s movement. I hope that this is basic enough for most people to get the gist of it. If you have questions, feel free to reach out to me on Twitter (Zeke Virant). Soft Body is available for PS4 and PC. Go to softbodygame.com for more info.

1. THE GUTS OF THE MOVEMENT

The following is a simplified version of the game’s movement code:

///this runs every frame
body.x += gamepad_axis_value.x * move_speed
body.y += gamepad_axis_value.y * move_speed

On every frame, the body’s X and Y coordinates are modified by the position of the joystick. The joystick returns a value that ranges from -1 to 1 for both the horizontal axis (x) and the vertical axis (y). I made this rough visual aid to give you an idea of the joystick’s coordinate system:

Notice that the joystick confines the values of the X and Y coordinates to it’s circular space. If the joystick is positioned exactly in the center, it will return (0,0). If the joystick is pushed to the right, it returns a positive X value between 0.001 and 1, and if pushed left, it returns a negative X value between -0.001 and -1. If it’s pushed down, it gives a positive Y value between 0.001 and 1. Pushed up, a negative Y value between -0.001 and -1. Lastly, notice that a position of (1,1) or (-1,-1) is impossible. As a result, circular motion is more prominent in the game.

To summarize: if the stick is pushed left or right, this affects ONLY the X value, and pushing the stick up or down affects ONLY the Y value.

The final value is the body’s move speed. The joystick values are multiplied by the move_speed variable, and it’s pretty straight-forward: the higher the value, the faster the body moves.

I decided against adding more complicated physics like momentum for two reasons:

  • I love the feel of the controller’s joystick and the gentle resistance and elasticity of its spring. The simplicity of a 1-to-1 movement system allows the physical sensation of maneuvering the joystick to take center stage.
  • I love responsive and tight controls in games and generally dislike action games that foreground the game physics with some sort of weightiness. Though momentum is great for emulating vehicular motion (like the spaceship in “Pixeljunk Shooter”), in my experience, weighty physics undermines the sensation of embodying an organic body.

2. A BEAUTIFUL, GOOEY SNAKE

Tightness and 1-to-1 movement controls play a huge role, but the flowing animation of the snake gives the game life and personality. In short, the body animation is just a bunch of different circles growing and shrinking.

This outlined version of the body should give you a better idea of how the body is built up of 30 or 40 circles.

Here’s a breakdown of how the body’s animation works:

  1. After the body has been moved to a new location with the joystick, a small circle is created on the body’s new location. A new circle is spawned every frame.
  2. For 10 or so frames, the circle steadily grows.
  3. After the 10th frame, the circle starts to shrink.
  4. Every frame, the circle has a 4% chance to begin wobbling. If wobbling is activated, the circle will move somewhere between -.5 and .5 pixels on both the X and Y axis every frame. This slight wobble gives the body a more organic, life-like animation. If the wobble isn’t activated for a circle, it never moves from its starting coordinate.
  5. When the circle’s radius is less than 0, the circle is destroyed.
Here’s the body with filled-in circles as it would be in-game.

It took me a while to tune the growth and shrinkage of the circles, but I thought it looked good from day 1.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Zeke Virant
Zeke Virant

Written by Zeke Virant

Lead Game Designer at MachineGames, developed the game Soft Body, make lots of music

No responses yet

Write a response