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
0
Question by Prodigga · Jun 19, 2012 at 02:49 AM · charactercontrollerprediction

Predict Charactercontroler movement

Hey guys, I want to predict where my Character would be half a second in time if he continues on his current path. But I am unsure of how to simulate the game X frames into the future. I cant just apply the current velocity of the character X frames worth of times, because if the character goes over a hole, he would have to fall in. any suggestions?

Comment
Add comment · 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 Mizuho · Jun 19, 2012 at 03:15 AM 0
Share

You should have your velocity based on Time.deltaTime so that the character's velocity is independant of the frame rate. Then you can just calculate it based on the Physics formula (from high school): v = d / t. You could shoot a raycast through the ground (ignoring the ground, of course) for the distance the character would travel to see if there are any holes they might fall into.

avatar image Prodigga · Jun 19, 2012 at 03:36 AM 0
Share

its a platformer, so the 'holes' are the edge of platforms. i dont see how that would work. that is - the characters 'edges' might collide with the platform, stopping him from falling. shooting a ray down wouldn't work properly.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Ipsquiggle · Jun 19, 2012 at 03:50 AM

If you are using the Unity physics system, this is quite a tricky problem. As you say, you'd have to simulate future frames, but as there is no direct manipulation of the physics system, there's no easy way to tell it, "Simulate this again! and again! and again!".

There are two possibilities in front of you, depending on whether you need a precise "location" of the character or just an idea of the environment around him:

1

If your physics needs are fairly simple, do the simulation yourself. Applying forces, velocities, and simple collision handling (you can still use the physics system for collision testing, with shape-casts!) is reasonably straight forward. Then you could just query your own system in whatever way you please to calcuate future frames.

2

This is probably the easier answer, but less accurate: Build up a set of "tests" using shape-casts and traces for the future position, e.g.

  • Is there open path ahead?

  • Is there a wall ahead?

  • Is there a hole ahead?

  • etc.

You will not get a perfectly precise position (so you couldn't, say, "show the player" where he's going to be in 1 second), but depending on your needs, you would probably be able to tell "things" like, "The character is about to fall in a hole!" and have it behave accordingly.

Comment
Add comment · Show 1 · 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 Prodigga · Jun 22, 2012 at 02:51 AM 0
Share

ended up doing idea 2, yeah. didnt need to 'simulate' the whole path it turns out. just getting an accurate idea of what is ahead was good enough.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How should I check if the charactercontroller is grounded next in the next calculation? 1 Answer

‘CharacterController’ does not contain a definition for ‘Move’ 0 Answers

Character controller Skin width no effect 0 Answers

Character Controller collision 1 Answer

[SOLVED] Character Controller moving at different Framrates? 4 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