1 min
When a person finishes a race in Mario kart it lerps round to be in front of the player. The link below shows the effect. I have been working on an orbit camera to do this effect. MARIO KART EFFECT
Since it need to circle around the player I knew I needed to use trigonometry. As Maths Is Fun shows, I need to use the opposite and the adjacent to get the hypotenuse. Once I had this it was easy. The center of the model was used as the pivot and the angle was changed to make it spin around the kart. M_dpos was a vector3 used to put the camera a set distance behind the car and to get the x of this vector was used as the opposite, the z was used to get the adjacent.
angle += amount;
sin(angle / radian) * vector3.x;
cos(angle / radian) * vector3.z;
The angle is increased by an amount every frame and the angle is then divided by a radian. The sin and cos of that result is then multiplied by the respective vector axis to get the position. Just by increasing the angle the position of the camera changes as shown in the image below.
This issues with this method is that it uses two dimensional maths, but I need it to work in three dimensions so what way the cart is facing it will orbit at the amount I want. For this I will have to incorporate the matrix and orientation of the car so it orbits around no matter how the car is rotated.
Subscribe to this blog via RSS.
Low level programming dev diary 28
Text based adventure dev diary 6
Level design developer diary 3
Game engine programming dev diary 14
Audio-visual production dev diary 7
Audio-Visual Production: Particle System Mesh Spawning Issues
Posted on 20 Feb 2020Low level programming dev diary (28) Text based adventure dev diary (6) Level design developer diary (3) Post mortem (4) Ex-machina dev diary (11) Game engine programming dev diary (14) Network game dev diary (11) Audio-visual production dev diary (7)