• 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 R4mz · Jan 28, 2018 at 07:27 PM · unity 52d2d-platformer2d-physics2d rotation

RotateAround using physics

Hey,

I am working on a 2D game where the player jumps from planet to planet and runs around that planet. At the moment I am working on the running around the planet part. I gave the planet a Point Effector 2D to simulate gravity, only problem I am having is that I want my player to run around the planet in a continuous speed. I could achieve this by using RotateAround() but when I try to apply jumping using AddForce() but then I get unexpected behaviour, where the player would be slowing down or speeding up at some points. What would be the best way to fix this while still using a Rigidbody? This is a small clip showing the issues. https://streamable.com/jmtly

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 LAZYGAMES_ · Jan 28, 2018 at 08:50 PM

Could you post your script that you are using to jump?
From the video I guess that you are adding force in a Vector up and right. But when the player gets added force to the right while rotating around the planet by RotateAround then the player will speed up as more force is added to the velocity the player already has.
Try to just apply force up as the player is moving sideways anyway.

Comment
Add comment · Show 3 · 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 R4mz · Jan 28, 2018 at 10:00 PM 0
Share

Currently I am probably using an odd way that is guaranteed to fail. I am using transform.RotateAround(planet.position, -transform.forward, movementSpeed * Time.deltaTime); and to jump I am using rb.AddForce(transform.up);. I know its not good to combine transform and forces, but I don't know how to make it rotate around the planet with forces.

avatar image LAZYGAMES_ R4mz · Jan 29, 2018 at 06:35 PM 0
Share

You have disabled the normal downforce of unity right? But if you want your player to just jump once and dont do double jumps your solution seems to work. If want the player to just jump once add a Collider on the player and check if he is grounded. the add the force to the player if he presses "jump" and is grounded.

avatar image R4mz LAZYGAMES_ · Jan 29, 2018 at 07:26 PM 0
Share

I want it to be able to fly around the planet aswell like it is doing in the video. Only problem is that the player keeps slowing down and speeding up. I was guessing it is happening because I am using transform and physics at the same time. Do you know a way to get the rota$$anonymous$$round function but with physics ins$$anonymous$$d of using it directly on the transform.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

219 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

Gravity Direction Change 2D 1 Answer

[2D] Sprite flickers/is choppy when moving 1 Answer

simulate gravity in a 2D game 3 Answers

Why is the Unity 2D physics engine only deterministic when Z axis rotation is frozen? 0 Answers

How to check if an object hits the ground hard enough then add explosive force around it (2D) 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges