• 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
Question by Corvidae · Apr 12, 2012 at 08:35 PM · physicsrigidbodyturn-basedpredictionvehicles

Turn-based vehicle physics

I'm currently working on a proof of concept for a turn-based car game. Each turn, you get to decide what you'll do over the next second or so, whether it's accelerate, turn, etc. I'm currently "pausing" the game by subclassing MonoBehaviour and having that toggle isKinematic on my rigidbody objects, which does a good job of freezing their movement. The vehicle physics are currently using a (modified) version of the AlternateVehiclePhysics package from the Unity car tutorial.

Here are my questions:

  • I'd like to have some way of predicting the player's location at the end of the next turn (barring collisions, etc.). In order to do this properly, I'd need to essentially run the physics for another turn, get the final location of the vehicle, then "rewind" to show the vehicle in the right position, but have an indicator of where the vehicle will be barring any changes. If you're going straight, the indicator would show the "end of next turn" indicator as being directly ahead, but if you pick the option to turn left instead, it would need to calculate the new position to your left and show the indicator there before you accept the command and actually execute the next turn. Does anyone have any ideas for a way to do this?

  • Once basic maneuvering is handled, I'd need to start implementing more advanced maneuvers, such as bootlegger turns, powerslides, etc. Any thoughts on how to "script" these maneuvers, so they can be essentially replayed over the next turn (i.e. accelerate for 0.2 seconds, then brake + hard left for 0.5 seconds, then moderate right for 0.3 seconds to level out)?

Thanks in advance.

Comment

People who like this

0 Show 2
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 jpeele · Apr 12, 2012 at 11:57 PM 0
Share

This is an interesting I idea for a game. for showing the next you could clone the car have it run for a turn while keeping everything else paused, store the clone transforms every x miliseconds in an array which would be your histogram for where the car will be.

I don't have any ideas about the manuvering though, it depends on how you handle it in the first place.

avatar image Corvidae · Apr 13, 2012 at 03:14 PM 0
Share

I thought about that, but it'd be a lot better if I could have it update as close to immediately as possible, given that players aren't going to want to have to wait a full second (or possibly up to 3) to see where they'll end up each time they tweak their settings for the next run.

Basic maneuvering would be done via the inputs (probably something like fake accel / brake pedals and wheel), while the maneuvers would be triggered from GUI buttons or something similar. Just wondering how I might be able to predefine them as scripts of the other inputs and be able to apply them at will.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Skidmark · Dec 27, 2012 at 09:01 AM

Q2: Perhaps not possible. Implementing a maneuver template that works perfectly on a flat surface with a uniform terrain surface type (asphalt or grass or sand or gravel) might be doable. Implementing a maneuver template that handles all possible cases of terrain slopes and surface type combinations would seem to be unsolvably complex.

Q1: Predicting position using a ghost car... I haven't tried out my new idea yet but here is my proposed approach:

I'm going to project the vehicle's position 1 second in the future with 0.1 second delay by modifying the game time variable to 10 x its usual rate during the "pause mode" when players determine and submit their next move. I will revert to normal time during "execute mode" when player input is disabled and the ghost cars are hidden.

Modifying the rate at which time passes in-game is pretty much universally considered a "bad idea". Emitters such as the smoke and flames from destroyed vehicles nearby would need to be correspondingly modified so that flames didn't flicker 10 times faster and smoke billow 10 times faster during "pause mode". I am sure there are other significant drawbacks to monkeying with the passage of time.

I'll still be setting the vehicles kinematic during "pause mode".

Vehicle ghosts will take the transform values of the corresponding vehicle and won't be kinematic. I don't want the two colliding when one instantiates inside the other. With current user input values, one tenth of a second later, that vehicle's predicted position will be shown by the ghost and then the ghost becomes kinematic.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Predicting A Trajectory 1 Answer

Calculating rigidbody top speed? 3 Answers

Predicting a Rigidbody's rotation in x seconds with constant deceleration 0 Answers

How to rotate with a Pid controller 0 Answers

Rotating a Rigidbody with Physics 1 Answer


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