Simulation in Games: Week 3

Week 3 already! In Tuesday’s practical session, we examined the concepts of acceleration, inertia and gravity and, as before, we were tasked with an implementation exercise. Oh, and I’ve made some progress on Spellcaster Academy!

Acceleration, Inertia and Gravity

Acceleration

Acceleration is the change of rate of velocity over time. Its equation is:

Acceleration equation

This equation can be rearranged:

  • velocity = acceleration * time
  • velocity = (directionalVector * acceleration) * time

In linear motion, if an object moves without acceleration, it will have a constant velocity.

Inertia

The inertia of an object is its resistance to change its state of motion, i.e., an object will keep its resting or moving state unless an external force is applied to it.

In relation to movement, inertia is important in stopping an accelerated, moving object.

Gravity

Gravity is a natural phenomenon where objects with masses attract each other. On Earth, objects are pulled towards its ground by a gravitational force of -9.8 m/s^2.

Exercise - An Application of Acceleration, Inertia and Gravity

The Tasks

This week’s exercise required the creation of three different Unity scenes. Each scene represents a sort of prototype for a type of physics game we could make.

2D Race Prototype

The first scene we were tasked with creating is a 2D race between three cubes: Two controlled by AI and one by the player, where:

  • The AI cubes should have a random constant acceleration and a random maximum speed.
  • The player should be able to stop with inertia by releasing all movement keys or pressing the spacebar.

2D Sailing Prototype

The next scene was to be a 2D player-controlled ship (in the shape of a cube) which can move in both X and Y axes, where:

  • The movement should experience acceleration and inertia.
  • The ship faces the direction of its movement.
  • The directional vector is displayed in the scene view.

3D Movement Prototype

The final scene is of a cube in 3D space which moves on the X and Z axes, while also being able to jump (Y axis).

  • The cube should experience gravity, collide with a ground surface and experience inertia.

The Implementation

2D Race Prototype

Race Prototype

As you can see in my implementation above, I begin with pushing the movement key which moves the player, letting go just before reaching the maximum speed of 2. The player then slowly stops with inertia after I release the movement key.

Though this is not depicted in the GIF, the AI cubes do have a random acceleration and max speed. These are determined using Random.value multiplied by 2.

2D Sailing Prototype

Here are two GIFs of my implementation, which should demonstrate all the requirements:

Ship Prototype
Ship Prototype in Scene View

3D Movement Prototype

A GIF which shows my implementation of a 3D movement prototype:

3D Movement Prototype

Spellcaster Academy

Last week I wrote about the kinds of spells I would like to have in the game (and showed you my moodboard). Since then, I have created a logo for the game and found some assets I’d like to use in it.

Spellcaster Academy Logo

I wanted the game’s logo to be whimsical, medieval and a bit playful. The font I ended up choosing is Kingthings Petrock, which provides the medieval element. To make it a bit more playful, as well as readable against backgrounds of varying colours, I outlined it in white and black. Finally, the whimsical element is the staff emenating magic. What do you think? Let me know in the comments!

The Assets

My search for assets started at the Unity Asset Store. I found some really nice Goblin and Spider enemies by PolyNext, which are great! I also found some skyboxes which fit the kind of artstyle I’m going for. The environmental assets in the Asset Store didn’t really wow me though, so I went looking for those elsewhere, until I remembered Kenny and his 3D game packs! His Castle Kit, Medieval Town and Nature Pack are exactly the right fit for the environment I want to have in Spellcaster Academy.

And that’s all I have for now. Thanks for reading. See you next week, by which I will have hopefully implemented player movement!

Written on February 17, 2018 | Tagged: Simulation in Games