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 craigiedon · Sep 01, 2014 at 10:34 AM · 2drotationphysicsphysics2d

Rotate a weapon in a circle around player

I'm making a 2 player game where the player controls a moving blue circle, but also wields a purple hammer which they can swing around them in a circular arc to hit a hockey puck with force:

circularArc

I have tried various combinations of components and parenting to get this to work. My most recent attempt involves putting a dynamic 2d rigidbody on the player circle, a dynamic 2d rigidbody on the hammer, then connecting the two via a 2d hinge joint. I then have a script attached to the player circle which rotates it using the rigidbody2d.MoveRotation(float) function.

The problems with this approach are:

  1. The player and hammer both rotate around the median center of the two objects. What I actually want is for the circle to remain stationary and the hammer to rotate around it.

  2. Although the hammer rotates around the circle, its local rotation stays the same (i.e aligned completely vertically). What I actually want is for the hammer to be at a perpendicular rotation to the angle the player is facing.

Another technique I tried was making the hammer a child of the circle with some offset. The idea was that when the parent player rotated, its child hammer would rotate with it. The problem with this method was that it would cause strange physics simulation problems where the player would end up "bumping into" its own child. After searching unity answers and the unity manuals I have found several resources which strongly advise against giving rigid bodies child rigid bodies.

Can someone recommend a good way to achieve the effect I am looking for using the unity 2d physics?

circular.png (21.9 kB)
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 Pyrian · Sep 01, 2014 at 12:38 PM

  1. There's a number of ways you could handle this, but the most physics-compliant way would be to simply make the player have a substantially larger mass than the hammer. Otherwise, you're going to have to make either the player or the hammer update manually.

  2. Hinge joints should rotate the hammer automatically (as opposed to a distance joint, which wouldn't), so are you sure you didn't just set fixed angle in it's settings?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to rotate a GameObject with another GameObject while simulating gravity? 2 Answers

2D plane physics, add torque based on direction 1 Answer

How to Rotate 2D Object Without Changing Axis Orientation? 1 Answer

Maintain equal physics over different UI sizes? 2 Answers

Rotate An Object Toward The Direction The Joystick Is Pressed, can you help me? I am stuck 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