19
\$\begingroup\$

When you set a personal best lap time in a console racing game, you have the option to compete against your ghost.

How can this feature be created for a single player casual type game?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ +1 Interesting question for one who is just a beginner in game development (me). =) \$\endgroup\$ Commented Mar 8, 2011 at 23:58
  • \$\begingroup\$ If you would tell us what kind of game it is, we could help you more specifically. \$\endgroup\$ Commented Mar 9, 2011 at 19:02
  • \$\begingroup\$ See also: gamedev.stackexchange.com/questions/6080/… \$\endgroup\$ Commented Mar 15, 2011 at 7:28

3 Answers 3

10
\$\begingroup\$

Ghosts are typically done by displaying a replay of a previous attempt. This replay is rendered with a non-collidable version of the players car so that you can't affect it. Since racing games often have a replay feature anyway this kind of comes along for free.

Here is a good starting point for building a replay system: http://www.gamasutra.com/view/feature/2029/developing_your_own_replay_system.php

Also there are a number of questions here on that topic:

\$\endgroup\$
1
  • \$\begingroup\$ +1 Just learned something new with your answer, thanks! =) \$\endgroup\$ Commented Mar 15, 2011 at 12:22
1
\$\begingroup\$

It depends on the technology you're working with. Hence, we can't really discuss of the best way, since it might change from a technology to another. The the gross idea in my opinion would be the following:

  1. Use an underlying data store to persist your data (XML, Cookies, Database, CSV, other...);
  2. Work your data access to this underlying data store;
  3. You need to keep information data about the best score of a player, so an identifier is required (email, input name, else...);
  4. Associate this best score to the identifier one way or another.

In short, assuming the use of a database, we could have two tables:

  1. Users/players data (identifier, email, etc.);
  2. Best score board information data.

Then, you could save the user information along with individual scoreboard which could, if desired, contain date and time registry as to when this score has been achieved.

I hope this helps and that I have correctly understood the question. Otherwise, please tell so that I may edit my answer accordingly.

\$\endgroup\$
5
  • 3
    \$\begingroup\$ I think he is likely looking for a recording/playback mechanism to accomplish this. Deterministic game environment, tracking events that change things (Player input for example) and the like are usually the recommended ways to do this. \$\endgroup\$
    – James
    Commented Mar 9, 2011 at 0:47
  • \$\begingroup\$ Thanks for your input James! These are stuff which I don't know about, though my answer is also a easily done approach, humbly. However, I'm interested to learn more on the topic. Oh and, +1 for your comment, this teaches me that there are other doable approach. =) Thanks! =) \$\endgroup\$ Commented Mar 9, 2011 at 0:56
  • \$\begingroup\$ i'm really sorry for this goof-up i'm still learning the basics thanks to both for your info, I can't really reply with proper knowledge because i don't possess any. what i want to accomplish is each time that i try to beat my personal high score that i see on the screen a ghost(replay) of how i played the game when i set my high score \$\endgroup\$ Commented Mar 9, 2011 at 1:23
  • \$\begingroup\$ @Will you are telling him information on what would could be done for a multiplayer setup, once he has actually figure out the answer to his question about a single player game. His question is how to create the ghost in the first place. \$\endgroup\$ Commented Mar 9, 2011 at 2:44
  • \$\begingroup\$ @AttackingHobo: Thanks for telling me. I actually have figured out from James comment about the recording thing, then having read wkerslake's answer, I now better understand what's being asked by the OP. Aside, you're right when saying that my proposed setup is more likely to be used in a multiplayer setup. Hey, I'm still learning here, and thanks for allowing to grow better! Game Development is still a new trick for me though I am an experienced developer. =) Thanks for your comment AttackingHobo! =) \$\endgroup\$ Commented Mar 9, 2011 at 14:24
1
\$\begingroup\$

Its not easy to answer this question without having more information on your game. The answer from wkerslake works as long as the current playthrough with the ghost can not affect the determinism of the recorded ghost data. If the recorded data is a single car time trial in a static environment, you should be alright using that technique.

However in many games with ghost playback, such as Super Meat Boy, the position of the player can change the state of the level and AI. Clearly, you can't have the ghost affecting the world and AI, so it might be better to just record position + animation changes (and anything else visible) every frame for the main player. During playback, just render the ghost at the current location and animation frame without having it be in the world. This allows you to playback a ghost and not have the current player affect it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .