Mario Kart Item Post 3

Overview

Implementations of bombs, triple banana peels, and singular and triple mushrooms

Bomb

The bomb is an item that when used starts a countdown which when finished creates an expanding explosion, hitting all players in its radius. Similar to the banana the bomb uses the in-built item trailing system to follow the player and can be thrown. But when used starts a 4-second countdown until it creates an explosion in the game scene by binding a create explosion function in the bomb class to one in the game scene (similar to how items are created). Once created, the explosion uses a vector lerp to increase its scale until it is ten times. Once the lerp is finished, the explosion is set to be destroyed in the game scene. When a player collides with the explosion through the collision manager the player gets launched into the air and flips using the same animation functions as with previous items. When either an item or a player collides with the bomb itself, the bomb detonates thus creating the explosion.

Triple Banana Peels

The triple banana peel works the same as the single banana peel except there are 3 of them, which trail the player in a line. To implement this a rework had to be done to the current item system. To start with the trailing item in the player class was changed from a single item pointer to a vector of item pointers. So when triple bananas peels are spawned 3 banana peels are created and pushed onto the vector. Then within the trailing item function, this vector is looped backwards through and every item except the last position is set relative to the previous item. When an item is released by the player, the first item in the vector is used and popped of the vector. The control scheme is also different for triple items, with the use button being pressed once in order for the items to all trail behind the player and then subsequent times to then use one item at a time. To do this a triple item bool is flagged when the bananas spawn causing which then causes the system to use a different input scheme where the items are constantly being trailed and pressing the use button calls the release item function.

Item Immunity

Initially, when triple banana peels spawned in a line behind the player, the collision manager would detect they were intersecting and destroy all three of them. In order to stop this without having to spread the trailing banana peels far apart, a vector of item pointers called immune items was added to the item class. When the triple bananas were spawned they each added their immune item vector to the trailing item vector. Then within the collision manager when checking to see if 2 items are intersecting the current item immune items are checked to see if the intersecting item is one of them. If so then the collision was skipped.

Mushrooms

Mushrooms are an item that doesn’t create a mesh when spawned, instead, they’re used instantly giving the player a temporary speed boost. The first implementation of mushroom boost was adding 10 times the player’s normalised velocity to their current velocity. This was too brief of an increase in velocity, however, so instead when the mushroom is used it sets a used flag to true. This is then checked for in the mushroom’s update function so when true adds 30 times the player’s normalized velocity to their current velocity. And since this is called in the mushroom’s update it applies this boost every frame. Lastly, a timer of 40 seconds was added when the item was used the countdown finished, the mushroom was set to be destroyed in the game scene.

Triple Mushrooms

The implementation of triple mushrooms worked similarly to triple bananas. When a triple mushroom are initially used by a player they use one mushroom and 2 more are added to the trailing item vector. When the player calls the release item one of the mushrooms is used and popped of the vector. The current inventory item is also not removed until all three mushrooms have been used.

Item box colliders

There was an issue with the size of the colliders for the item boxes where they were too small to hit. The colliders were the same size as the mesh but it was hard for players to drive directly into them in order to get an item. To stop this issue I added an addition scale float to physModel which is multiplied to the scale to set the extents of the box collider. I then set this additional scale to 50 in the item box class. Because of this, the item box’s colliders were much larger and easier to hit.

Previous
Previous

Mario Kart Item Post 4

Next
Next

Mario Kart Item Post 2