Mario Kart Item Post 8

Mario Kart Item Post 8

May 5, 2019. | By: Evan Diamond
2 mins

The eighth post in making items for mario kart in DirectX12

Overview

Red shells and collision manager config

Red Shells

Red shells are a common item in mario kart. When used they target a player and drive along the track. Once within certain distance of the player they move towards them and try and collide with them. If they hit a wall or another item they’re destroyed.

Red Shell

When used the red shell class’s velocity is set to the using player’s normalised velocity and multiplied by the movement speed of the shell. If the shell’s alternate use is being used it sets it’s velocity to negative the players and does not use ai. This makes the shell go backwards from the player and is destroyed when it collides with an item, player or wall (this happens in mario kart too). If alternate use is not used then red shell ai’s waypoint is set to the players current waypoint and it finds it’s target player. To find the shell’s target player all the player’s are passed into the red shell class on construction as a vector of player pointers. When the shell is used this vector is then searched to first of all check any player’s who have a greater or equal to rank of the using player (player’s behind in the race). Next it checks to see if the target player pointer is nullptr if so then the target player is set to the current player. Otherwise the current player’s ranking is checked to see if it is greater than target player, if so then the target player is set to the current player. If no target player is found then the players are searched again until the player with the lowest rank that isn’t the using player is found. The target player is then set to this. Once the target player is found the player vector is cleared

Once the item is used and the target player is found the red shell’s update function calls the ai’s update function. This is until the distance squared between the red shell and it’s target player’s position is less than a certain threshold (stored in the item config json). At this point the red shell deletes it’s ai and does and creates and moves towards the target player using a move towards vector. This vector is made by finding the difference between the target player and the red shell’s positions, normalising it and multiplying by the red shell’s speed. This vector was originally made once but rarely hit it’s target, so instead this move towards vector is calculated every frame until it is destroyed.

Collision Manager Config

Some part of the collision manager still had hard coded values such as the minimum distance square between physmodels before they’re checked to be intersecting (recently added) and the collision response data when a invincible player collides with a non-invincible player. No deal with these hard coded values they have been added to a collision manager config json file.

About

Gamers developing new games.

Social Links

Our Bunker

University of the West of England,
Frenchay Campus, Bristol, BS16 1QY,
United Kingdom.