Being sick over the weekend I was seriously panicking. I had no idea how I was going to write the ghosts.
The problem with the ghosts is that there position is dynamic: depending on input from the player for different parts of their positioning, and then they have to find the track.
For instance: let’s do the ghost for player one.
So player one is at
- p1=(x,y,z) and rotation r1= (x,y,z).
Player two is at
- p2=(x,y,z) and rotation r2= (x,y,z).
For ghost one (the ghost for player one), we need determine AT RUN TIME the following:
- g_p1 = (x, y, z), and g_r2 = (x,y,z)
Problem Rotation: we wanted the ghost to mimic the rotational movements of the player. So if they were moving left, right, or had flipped over, we wanted to show that on the track.
Solution Rotation: So rotation, in 2D space, should be g_r2 = r1 for x and y. We don’t have to worry about z rotation because the road is flat (we’re not in 3 space). Only you do want to show when a player crashes, so z rotation of player1 does matter. Aye, aye, aye. I just assigned g_r2 = r1 in 2D space for now, but this became a major issue in 3D space.
Problem Position: The position of the ghost should somehow measure the distance that player1 has traveled on the path player2 is on if he’d taken the same path as player2.
Problem Metric: How do you measure the metric and what should the metric be?
I had several long conversations about what the metric would be with many different people many different times. In fact, in two different talks with the professors we talked ourselves around to the others ideas, which left me back at square one. What is the metric. Here were all the ideas I thought of and considered. The ones I thought would work the best were from start to current, or relative closest behind.
- The ideas ranged from
- Measuring the distance traveled from the beginning to the current position (easy)
- Measuring a relative distance to the other player by measuring backwards to the closest fork and finding the best path
- Measuring the best, worst, or average distance to the end.
- Use some type of displacement
Solution z-position: For this I called in help from a friend. Ben Driggs came over late and we discussed the issue. Since the race I was making happens mostly in 2-space he suggested making the metric the displacement in z. Not a true measure of distance, but a place to start!
Problem Position x,y: While this gave a resolution to the z problem, it didn’t solve x and y. I didn’t have a lot of time to figure something complicated out, and since player2 is the one that needs to see the ghost I slapped on the ghost’s x,y as determined by player2. This meant that effectively player1’s ghost “floated” in space (the backdrop of the race was in the air!), but it gave an excellent place to start for play testing to see if the ghosts were fun at all.
So to sum up:
- g_r1 = r1
- g_p1 = (r2.x, r2.y, r1.z)
We also had the art added in with arrows, landmarks, and a finish post. It made the race super fun. We found that having the ghosts on the path with us did provide that head-to-head feeling of having other racers with you and still allowed for you to choose the path you wanted to go on. So the demo was a success.