Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Recording movement for ingame playback

Discussion in 'Scripting' started by OXYGEN, Sep 20, 2008.

  1. OXYGEN

    OXYGEN

    Guest

    Joined:
    Mar 16, 2008
    Posts:
    1,101
    Hi community is it possible to record the movement of my charector in realtime in unity?

    and then play it back as a cut scene in unity in real time.

    for example i wish to drive around my world interact with the world and play all the movements i created as a cut sceneis it possible?
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    It sure is possible, but how you'll be able to do it depends largely on the implementation of your game (which depends on the type of game you're implementing).

    What I'll be doing for Traces of Illumination is record the "key events" (mostly the commands the player issues, like "turn left, turn right, use power-up XY"), with time and location - and store those on the database server that the game server is connected to (so this is all handled server-side). Then, I can "reload that session" and replay it.

    I've already done some experiments with "just setting up a staged scene" in the Unity editor, and that's working pretty nicely (some of this can be seen in the third tutorial) - but there are also some inaccuracies which make it a little bit tricky (in a game like Traces of Illumination, that's a problem - in other games, you might live with those inaccuracies without a problem, in still other games, inaccuracies might be completely unacceptable).

    As far as I can see, inaccuracies create most trouble when you're dealing with physics (stuff bumping around) because there, those inaccuracies might add up to an unacceptable level.

    Another question is obviously, what you want to record. I'm using "commands" (with locations for "error correction"), but sometimes recording some sort of "keyframes" might also make sense. The advantage of using "commands" is that you should be able to use most of the existing game logic for replaying the "sessions".
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    <shameless plug> I have a recorder script that does this.</shameless plug>

    I would honestly strongly recommend against keystroke recording except for the simplest, most predictable of games. Recording position data is easier and far more reliable (and compressible)
     
  4. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    That recorder script looks cool. I guess for simply recording and replaying character movement, that's probably the ideal solution.

    Considering a more general use case, though: How would it handle instantiation of objects, e.g. if you shoot projectiles, cast spells (e.g. with particle effects) or the like?

    I guess in most cases, some combination of recording position data and commands will probably yield the best results, even though one could consider "position change" simply one specific type of event (it makes sense to separate that from other events, though, as it usually occurs much more frequently).

    Re-reading my original posting, I just noticed that I expressed myself in a way that's probably easy to misunderstand: With "key events", I didn't refer to keyboard events, but "key events to the game play" - in other words, those events that matter most in respect to replaying. So, my recommendation was not to record keystrokes but thinking about what specific kinds of events make most sense to be recorded (which is much more abstract than keystrokes).

    Like, if for instance you have some enemy AI that does certain things with a certain randomness (e.g. shoot at player), and others in a deterministic manner, it may make sense to just record the random based decisions while relying on the usual gameplay logic to handle the deterministic stuff.
     
  5. OXYGEN

    OXYGEN

    Guest

    Joined:
    Mar 16, 2008
    Posts:
    1,101
    Thanks for the reply Guys

    Jashan you mentioned the third tutorial?
    were is that located buddy?



    and starmanta loveing the record feature script private messaged you
     
  6. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    In this Web player, if you're new to the camera controls, you should probably do tutorial 2 first ;-)

    I used an early version of the approach mentioned in my previous posting in steps 3 (Jump), 4 (Smoke), 8 (Shoot Trace) and 9 (Bullet Time) of that tutorial 3. That early approach only uses time, I've now extended that to also use location.
     
  7. OXYGEN

    OXYGEN

    Guest

    Joined:
    Mar 16, 2008
    Posts:
    1,101
    Hi jashan love the game! great music top game play likeing it lots

    but regarding tutorial links was thinking you would be directing me to a tutorial on how to implement the record features in unity.

    anyway glad that I had a quick spin of your game kudos its ace dude Highly recomend it to the community

    to the younger community members check out the DVD TRON
     
  8. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Hey StarManta,

    I think I am late here, your script is not available now. Can you provide it again?

    Rahuxx
     
  9. ToroidGames

    ToroidGames

    Joined:
    Jul 25, 2017
    Posts:
    11
    I came across this post - sigh another lost script.... anyhow after some research I found this brackeys tutorial that spells out how to Record Movements without recording KeyPresses. The method employed records position and rotation data. The video also covers playback and essential usage of FixedUpdate rather than Update. As usual Brackeys rocks!