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 Dibbsie · Aug 09, 2016 at 05:17 AM · gravityplanetrunnercontinuous

How to make a continuous runner on a planet with gravity?

Hi, I am looking to create a continuous runner game around a planet and am having a hard time getting the player to continually move around the planet and adjust their direction/rotation to match when the left/right keys are input. Anything I have is pretty useless so far so have no code to post. Note I am quite new to Unity so apologies if this is a stupid question. Any help is appreciated. Thanks

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
1

Answer by Sherlore · Aug 09, 2016 at 09:02 AM

I guess one of below design may help you.

Design A: Runner actually doesn't move and rotate in scene. Make the planet and background rotate reversely, so that runner seem like running forward.

Design B: Runner actually run on the planet.

Runner's rotation always depend on vector (planet.position - runner.position)

//e.g. y-axis always match vector (planet.position - runner.position)

.

and for gravity

B-1: To make runner receive gravity, continuously change Physics.gravity to vector (planet.position - runner.position)

B-2: Don't use Physics.gravity. Set all object with rigidbody not use gravity. Create trigger for planet as gravity zone, when object inside trigger (onTriggerStay), use AddForce with direction (planet.position - object .position) to simulate gravity

Wish these could help you, good luck!!

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 Dibbsie · Aug 10, 2016 at 05:10 AM 0
Share

I have gone more with option B above and managed to get part way to my goal. I have an object starting on top of a sphere and it begins to move in a direction at a constant speed. To work out where to go I am getting the direction it is facing, multiplying the speed to the vector to deter$$anonymous$$e the target position (directly ahead and off the sphere). I am then using a raycast to deter$$anonymous$$e where the hitpoint is on the sphere and lerping to that position.

Some issues i now have is all around rotating the object. How do I deter$$anonymous$$e how much to rotate the object between its current position and its target position? Vectors that I know include: current position current up (player position - planet position) current direction target position (based on horizontal input, movement speed, raycast hitpoint) target up (target position - planet position)

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

6 People are following this question.

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

Related Questions

how to apply orbit to the player 2 Answers

Implementing FPS view into locomotion planet walk 1 Answer

how to make gravity in the center of a sphere 1 Answer

Adding a force(gravity) to a planet. 0 Answers

Continuous instantiation of a moving prefab 2 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