- Home /
Record "ghost" in car racing game
Hi there,
I was wondering how to record a "ghost" of the player driving a vehicle.
What comes into mind is to write the translation and rotation of my car into some sort of array every tick and then, when re-playing simply moving a "ghost" type along the exact positions from the array.
Is this how it is normally done in actual video games?
@Fattie - one thing you forgot to mention, and that @Somian might want to notice - is that "ghost" player replays are protected under patent owned by $$anonymous$$idway .... http://www.gamasutra.com/view/feature/1489/hard_drivin_hard_bargainin_.php
Hi @tano, that's a fascinating legal point, thanks for the link. Note that --- say --- the idea of a "mouse" or basic "touch screen" concepts are in hot legal dispute, in certain jurisdictions. Note too that that "submarine patent" covers the general concept of doing ghost racing, it has nothing to do with the implementation of it. Under discussion here is how to implement it.
FTR on the legal front, I've worked on many large racing and car games for various entities, and everyone ignores this patent issue (much as with a "mouse" or "certain touch screen concepts" or the "gif patent issues".)
You're right - I think it's very unlikely that the patent owner will bother knocking on the door of your average Unity developer making a racing game who, in all likelihood, is likely to be completely unaware that they were infringeing a patent ;) But, lack of knowledge is no defence against the law, and I think it's a little known fact so I just thought I'd bring it up here!
Answer by Fattie · Aug 19, 2013 at 01:17 PM
http://answers.unity3d.com/questions/327275/how-do-you-record-the-movement-of-an-object-and-th.html
"What comes into mind is to write the translation and rotation of my car into a (List) every tick and then, when re-playing simple moving a "ghost" type along the exact positions from the array."
Yes, it's that simple. That is exactly how it is done in every car game.
To get you going, just work at 10hz, that is fine for any race game. But feel free to try 50, 5, 20, or whatever you want.
"That sounds slow to me, though :X"
It's rather bizarre that you would think that! It uses what can only be described as "zero" computing power. You're only setting a few variables a few times a second. Things like "the physics engine" would, literally, use perhaps 10 MILLION TIMES more calculation power.
Again this question comes up a lot and it is very strange. So party on, and do exactly what you first thought. You were right. You simply save the position (and any other data you want - rotation, whether the door is open, etc etc.)
Haha, thanks, Fattie! I just did the math and worked out that a 2$$anonymous$$ replay that had all the variables (car and wheel rotations and positions) stored 60 times a second would only be around 500kb. And you don't even need to move the car between points, just set its transform and rotation. Hardly a memory killer. I was trying to work out how to make my game deter$$anonymous$$istic but I simply don't need to. :D This system probably wouldn't be great for REALLY long replays, but perfect for my game with shorter stages. $$anonymous$$uch easier than I thought :)
As I said, it's an incredibly well-explored engineering question. And it's very simple, fundamentally it's only a few lines of code. Try it out and see how you go. $$anonymous$$ake it very easy to TUNE the Hz rate at which you save the data. You actually don't need to bother that often. As little as 10 can work fine. Enjoy
Indeed. Less points for the win. Slap in some interpolation on playback so you don't see any jumps.
Just FWIW $$anonymous$$eat (having worked on this engineering many, many times on popular games you have often played), just purely in my experience you generally don't need any interpolation. It's worth noting that - say - something like "playing the background music" would use - literally - 10s, perhaps THOUSANDS (!) of times more computing power than this. Something like "the sound effect engine" or "the engine for drawing the score on the screen" or "handling all the buttons and controls" would use, easily, a $$anonymous$$ILLION TI$$anonymous$$ES more computing power than this. The whole thing is a non-issue: it's really strange that (I've seen on forums) people often oddly think it will be some sort of problem. Anyways - enjoy!
dude you'd definitely just store it on parse.com - so easy
i strongly, strongly recommend fooling around with parse.com - it's amazing and incredibly simple.
(you could also use apple's game thing I think, or any other "BaaS")
Also - just from experience - i've found say 30 - 40 kb is typical for a race for one vehicle. (it's amazing what a low frame rate you can get away with.)
but most importantly - you can compress the file, if needs be! they compress down to nothing. intriguingly, this is mathematically similar to interpolating!!
Answer by SamohtVII · Feb 21, 2019 at 05:46 AM
This may be an old thread but i have created exactly what's described and put it on the asset store
https://assetstore.unity.com/packages/tools/integration/ghost-recording-and-replay-script-138922
I have been using it for my current game and works perfectly.
Answer by mbcampos · Sep 06, 2021 at 09:36 AM
the other way is save the players actions (power, brake, etc) + time in a array. And load with as a car player with another tag. The good point is, less data, less complexity and more realist. Will be a real car working as a recorded player action.
Your answer
Follow this Question
Related Questions
Why SSAO creates ghosts on non-billboard grass? 0 Answers
Running Trail Ghost Behind 2 Answers
Effects On An Entire Scene 1 Answer
Time Trial & Ghosting 1 Answer
Remove Ghost image on android 0 Answers