Big Game Project – Post 3

The course is over and this blog was ignored in favor of production so I will be writing three blog posts summarizing the third, fourth and then the final weeks or the project.

First is the third week.

This week I finished our gravitational system with the simplest solution: using the previously mentioned raycast that finds the normal of the mesh below the ship and then move the ship to a predetermined distance away from the mesh along the normal, pseudocode:

newPosition = RayCastHit.point + RayCastHit.normal * distance

This worked surprisingly well and is the solution used in the final game.

Another thing I added this week was splitting the screen based on the number of controllers connected.
How it worked was creating a player prefab for every controller connected and then changing each players camera viewport based on which controller it was (checked using XInput GetState with valued 0-3 for players 1-4).

Finally I created the basic waypoints that made the following things functional:

  • AI Navigation points
  • Player placement
  • Lap count
  • Wrong-way indicator
  • Respawn position/rotation

I will only be adressing the first point in this post about the third week as that was the only thing they were used for at that point.

The AI racers are not very good at anything here, they have a LookAt (basic method in Transform for Unity) and then a move forward to go towards the waypoint.
The waypoints themselves were manually placed in the world but with assistant scripts that spawn them using Unity editor magic.
This is what I used:  https://unity3d.com/learn/tutorials/modules/intermediate/editor/adding-buttons-to-inspector
First thing I made was a button that created another waypoint, makes it a child of the parentobject designated in the script, names it depending on the current childcount of the parentobject and then places it at 0,0,0 in the world.
That wasn’t good enough for a tool that should simplify the placement of the waypoints, so I added an object called Starting Area that was used for spawning the players on the track where it begins. Next I added a button that did the same as the last one but positioned it on the starting area object.
To accompany this I made a button that creates a new waypoint on the position of the last waypoint in the hierarchy.

With these buttons the process of placing waypoints around the track was done in much less time than placing them out in the world manually would have. (Since this was done when the final version of the track was not yet done and waypoints could not even be placed yet)

 

That was, from what our SCRUM document along with what my memory says, the major things that were added on the third week of production, up next is week four.