Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tanoshimi2000 · Oct 09, 2015 at 02:00 PM · rotationpositionrecordingplayback

Best way to record/save race car runs

So, I have a racing game mostly done. Now I want to be able to record the car's run so that I can play it back. I'm NOT trying to record video, or the screen, or the game, I want to record the car (GameObject) so that when the next racer races, they can race against the previous run. So it will be a completely new game, but a bot racer (computer controlled gameobject) will replicate the previous or best run.

What's the best way to do this? Record the position and rotation with AnimationCurves, then read those curves and set the position/rotation later? Create a custom asset that stores the position and rotation and then uses them to set the bot's later? Wouldn't that be a lot of data if captured each frame? Maybe just store rotation and speed, and let it replay those to establish position?

Maybe there's an asset out there that can do this, but most of what I saw were scene based, or didn't save. I just want to track the car's position and rotation, and use that data later. Suggestions?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FortisVenaliter · Oct 09, 2015 at 02:44 PM

There are generally two ways of doing this...

The first is to store position and rotation for every frame. At the end of the race (or if the amount of data exceeds some threshold), you then process that data into a series of curves which can be saved with a much smaller footprint.

The second is to store input. Store when it accelerates, decelerates, and turns. That will have a much smaller footprint initially, but if it's not perfect, any error can get exponentially worse very quickly.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tanoshimi2000 · Oct 09, 2015 at 02:49 PM 0
Share

Right. I figured on storing input, but I don't trust it. So it boils down to finding the best way to store the rotation and position for the car. I'm thinking I don't need every frame, but maybe every other, third, or even 10th frame; whatever won't look jagged on playback.

avatar image FortisVenaliter Tanoshimi2000 · Oct 09, 2015 at 03:01 PM 0
Share

Yeah, that's what I was saying about boiling it down. Store it every frame, but then reduce that to splines that only have a frame or two a second, but look good regardless.

avatar image meat5000 ♦ · Oct 09, 2015 at 03:06 PM 0
Share

Just save the transform.position/rotation to a List. Set the routine to only do this every x distance from last point to make the data consistent or do it by time period to Automatically give a sense of speed.

avatar image Tanoshimi2000 meat5000 ♦ · Oct 09, 2015 at 04:31 PM 0
Share

Right, that's what we're discussing. Storing the transform's position and rotation every half second or so, but then using splines to interpolate the spaces in between. $$anonymous$$ore ore less keyfra$$anonymous$$g the animation. I was just wondering if there were built in methods for keyfra$$anonymous$$g, and storing them, or if I was going to be forced to write my own, like the ListOf that you mentioned. Since all I need is the position and rotation, I'd probably make my own class that only stored those two items, so I could make a ListOf();

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Position and rotate 3 sprites perpendicular to the edges of a triangle 1 Answer

How to make rotation return to starts after key release? #c 1 Answer

Objects Instantiating at wrong position 3 Answers

How do I get the Rotation postition of a gameobject 1 Answer

transform.forward doesn't work in my code 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges