Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by RyuK · Apr 11, 2014 at 07:37 AM · 2dphysics2d-physicsreverse

How to do time reversal with Unity2D / Physics2D?

Hi guys, could you share your thought about how to do time reversal in Unity2D? I mean, is it possible to do it with Physics2D, and if it's not possible, what options are there? Giving up physics and using some tweener to implement reverse animation?

Comment
Add comment · Show 4
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 Denvery · Apr 11, 2014 at 11:34 AM 0
Share

Do you want to make reverse mechanim animation or physics 2D reverse effects (i.e. reverse gravity etc)?

avatar image flamy · Apr 11, 2014 at 11:49 AM 0
Share

Are you expecting something like braid game?!

avatar image RyuK · Apr 13, 2014 at 06:06 AM 0
Share

Yes, I'd like to mimic the effect of the Braid game where you can reverse all the objects' move backward, while using physics2d to control objects. Is there any difference/optimization in doing it in 3d or 2d?

avatar image Lachee1 · Apr 13, 2014 at 06:58 AM 0
Share

Sadly it is not possible to reverse Time.timeScale, so the only way I could think is using a Playback (or replay) script and play the events in reverse order. $$anonymous$$aybe something like http://u3d.as/content/soft-rare/ez-replay-manager/1QY or if you wish to make your own, http://www.m2h.nl/files/replay/replay.pdf is a good reference

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Apr 13, 2014 at 07:12 AM

Here are a few thoughts.

I consider you can only replay x amount of seconds, not the whole game.

Create a manager that holds a list of object. This list implements IComparable with a Compare method that will check each object for time and activity. So for all objects it checks if it is still alive, if so, do nothing, if dead, has it been dead for more than x seconds, if so remove from the list. This allows you to revive object in your backward process that were dead recently.

If you only replay Transform then you only store your transforms in a queue. The point of a queue here is that you place the most recent at the end and remove the oldest one at the front. You then only need to play backward. If you need to record other happening, then you could use your queue but storing object of a class you defined. The class qould have Transform and other states you need to keep track.

As you go backward in your queue, first you stop recording and second you read the info. For transform you simply need to interpolate from current to next (which is actually previous), as you get to next info, you check if there has been a record for other modification, like color or it got destroyed/deactivated so now you need to reactivate it.

In order to avoid all kind of check for each object, you could have them inheriting a top class with an abstract method in which for each Subclass you implement in the proper way. Then in your backward class you just call that method for all objects regardless what it does in the implementation.

Those are just thoughts but maybe that will give some directions.

Comment
Add comment · 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

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

25 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

Related Questions

How to convert Torque Stabilizer to RigidBody2D? 1 Answer

HingeJoint2D.GetReactionForce not working 1 Answer

Using animated transform to push object away? 2D 0 Answers

Paper Ball Physics Implementation 0 Answers

How to drag and throw 2D objects?(SOLVED) 5 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