playMaker

Author Topic: Record and play ghost car[SOLVED]  (Read 2549 times)

persabersa

  • Playmaker Newbie
  • *
  • Posts: 9
Record and play ghost car[SOLVED]
« on: September 09, 2017, 06:55:34 AM »
Hiya,


Im making a race arcade game and I would love to add a feature where you race against a ghost car. So Im wondering whats the best way to record the movements of a car and later play them back?
Do I make some kind of store position and rotation every frame or will that get superheavy, and how would I store and read those even?
Any help is super appriciated!

Cheers
Per
« Last Edit: September 20, 2017, 04:37:14 AM by jeanfabre »

gozda

  • Junior Playmaker
  • **
  • Posts: 88
Re: Record and play ghost car
« Reply #1 on: September 11, 2017, 04:10:28 AM »
Good question.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Record and play ghost car
« Reply #2 on: September 11, 2017, 04:22:18 AM »
Hi,

 yes, you would sample position and rotation every nth time and save it in an array. you'll also like need to save a timestamp with each sample so that you know when to show a particular sample ( or loop through the array with a timed loop system).

 don't use FsmArray for this, it will be not optimal, prefer using ArrayMaker which uses lists that can grow without affecting perfs. FsmArray uses built in arrays which are best to use with a fixed size, and at least not a ever growing list during the game loop.

 http://answers.unity3d.com/questions/227657/record-ghost.html

also, you'll need an interpolation system to move smoothly the car between each sample, that's likely more tricky then recording actually.

 maybe, you could search for splines and path systems on the asset store and ask them if they have such solution already built int, you might find something cool.


 Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Record and play ghost car
« Reply #3 on: September 15, 2017, 10:49:16 PM »
Hi,
This is something cool and has playmaker support.  8)


persabersa

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Record and play ghost car
« Reply #4 on: September 19, 2017, 05:13:33 PM »
Hiya,
Thanks alot for your answers!
I didn't check the forum for a while but I read up on array maker, and managed to do what you described before I read your answers :). Record one array for position and another for rotations.
Then playing them up with the same loop speed as it is recording. Works like a charm, I don't see any performance hit in the profiler!

Im using chronos to be able to slow down and reverse time, which seems to work fine with the array record and playback.


Thanks again!

Per