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 Nonakesh · Oct 27, 2012 at 02:23 PM · rotationrigidbodyaddforce

Rotate rigidbody around point

I need a way to rotate a rigidbody around a specific point. The problem is, that it should react realistic and I can't use a fixed joint for it.

What I'm looking for is AddTorqueAtPoint(Vector3 torque, Vector3 position)

Of course this method isn't implemented, but there should be a way to rotate the rigidbody correctly by applying two (continuous) forces on the opposite sides of it, but I can't figure out how far away from the center and how strong these forces should be.

EDIT: I'll try to clarify what I'm trying to do. I have multiple objects that have the same parent. The parent has a rigidbody. I want to add a torque to one of the child objects so that it rotates to a specific rotation (using a maximum of force, so that it still interacts correctly with other objects)

The reason why I don't want to use different rigidbodies that are connected with joints it that the objects should stay absolutely fixed together. Connecting rigidbodies results in very strange vibrations in the objects, which makes it impossible to use for the game I'm working on.

EDIT2: Here is a small sketch... I hope that clears up what I'm trying to do. Thanks to those who already tried and thanks in advance to those who will (hopefully) help me later!

alt text

rotatearoundpoint.png (9.7 kB)
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 Nonakesh · Oct 27, 2012 at 09:04 PM 0
Share

That wouldn't work because the rigidbody wouldn't be accelerated realistically. I want it to rotate with a specific force, not with a specific speed.

avatar image Nonakesh · Oct 27, 2012 at 09:12 PM 0
Share

If I parent the rigidbody to a empty and rotate it, I will only be able to specify its speed, not the maximal rotation-force...

4 Replies

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

Answer by Bunny83 · Oct 27, 2012 at 09:29 PM

This is near to impossible with applying two forces blindly. The Physics system calculates the inerita tensor from all the rigidbody's colliders.(See Unity's inertiaTensor and inertiaTensorRotation) This tensor will affect how likely an object will rotate around a certain axis. Generally all forces applied to a rigidbody will result in a combination of a linear movement (velocity) and a rotation around the center of mass in one axis (angular velocity).

What you want is near spaceship science and they know every parameter of their ship. Besides that Physx is a physics simulation which just simulates real world physics, but the result is never accurate.

The best way might be to calculate a path to your target (great circle or elliptic) and just continuously set the rigidbody's velocity manually to the tangent vector of your path.

Comment
Add comment · Show 5 · 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 Nonakesh · Oct 27, 2012 at 09:49 PM 0
Share

Thanks for that answer! I already was afraid that it would be a bit more complex than I thought at the beginning...

I think I'll describe what I'm trying to do a bit more detailed, maybe you'll be able to help me... Of course it isn't realistic at all, but I try to let it look as realistic as possible in the setting of the game. I'm making a RTS where you are playing on flying islands, that can be connected to expand the players territory. I have tried to connect the islands with fixed joints, but that caused strange vibrations which made the game unplayable in the end... what I thought of was to parent the islands to a empty and adding a rigidbody to the new parent (and also delete those of the individual islands..). I did add the masses of the islands together and it reacts still as it should.

Now here is where the actual problem is: The islands are moved by some sort of huge airship that is mounted on top of a single island. I want the player to be able to move their base to a specific point and with a specific rotation, but I want that the island complex is rotated much slower when the island-transportation-airship is mounted on a island that is further away from the center of mass. That's where I would need a "AddTorqueToPoint()" method...

As you can see that is a very basic feature in the game, so I would REALLY appreciate any help, be it a solution for my current system, or a alternative system that would work... Thanks for your help!

avatar image Fattie · Oct 27, 2012 at 09:56 PM 1
Share

(1) if you want some unusual movement ... just animate it. it's that simple. just move the things where you want at the speed you want using some path system, or whatever works for you

(2) do what B said just animate the velocity as you wish

(3) FTR I still can't at all understand the set up here. Could you draw a diagram?

Unfortunately this critical sentence "but I want that the island complex is rotated much slower when the island-transportation-airship is mounted on a island that is further away from the center of mass" does not make sense to me, it has a superfluity of iss.

At one point you say "I want it to rotate slower .." [because of some game feature .. the airship image is placed elsewhere or whatever]

O$$anonymous$$, then just rotate it slower. Set the rotation to be slower.

Just include a screen shot or diagram perhaps for more help

It sounds like an interesting problem but there's a tradition on this site of questions being ... not quite like they seem. Halloween.

avatar image Nonakesh · Oct 27, 2012 at 10:10 PM 0
Share

I didn't decribe that very well, of course it is independent of the position, but it's dependent of the mass. I don't want to just add the rotation, or animate it. Imagine you connect many islands in a row and rotate it around one island on the side. The island on the other end would have a unrealistically high speed. What I want is that the airship has a specific force to rotate islands... if you connect multiple islands the total mass is much higher, so the rotation speed would be much slower. The connected islands should still react as if they would be individual rigidbodies..

Of course if there would be a way to perfectly connect multiple rigidbodies, without any strange behavior, even when connecting many of them (like a big base that consists of large numbers of islands), that would completely solve the problem!

By the way, I can't upload a screenshot because I don't have any visuals for the connections yet, so it would probably just be confusing...

avatar image Bunny83 · Oct 27, 2012 at 10:29 PM 1
Share

Your best alternative is to set the center of mass to your desired rotation point. $$anonymous$$eep in $$anonymous$$d that all rotations which might affect your whole island object are applied around the center of mass.

http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-centerOf$$anonymous$$ass.html

$$anonymous$$eep in $$anonymous$$d that the center of mass is in local space coordinates relative to the rigidbody's transform.

avatar image Nonakesh · Oct 27, 2012 at 10:37 PM 0
Share

But would it still react the same way? It would also make it impossible to use multiple transporters, but I guess that would only cause problems anyway...

I think the best and easiest way to solve this problem is, that the transporter moves to the center between the islands. That way it would still be possible to rotate it normally!

Thanks for your help! Even if it's not the solution I wanted at the beginning, but at least you helped me to find a new solution that is probably even better from the players point of view!

Sometimes I'm just too focused on a specific problem, so that I don't see the easiest way any more...

avatar image
4

Answer by Jack Al · Feb 08, 2013 at 11:38 AM

Hi, the question seems to be old enough, but perhaps my answer can be useful for later readers. I've had the same problem - needed to rotate the rigidbody around some center (other object). Had very bad days trying to calculate the physics on my own, but finally got it working with simple HingeJoint. You may have tried this, but I achieved to make it work without any vibrations of rotating object. You just need to make sure that:

  1. you're not using any springs on your hinge joint (center)

  2. the applied forces are perpendicular to the connecting vector of these objects (center and rotating object).

You don't need to change the gravity center of rotating object in this case. Just make your center's rigidbody NON-kinematic, but freeze all position axes. Also freeze the rotation axis of HingeJoint's enabled axis. I.e. if you have enabled axis X on hinge joint, freeze this in rigidbody.

Now your center object will rotate around itself (this doesn't matter) in all axes except the one that makes the orbital object rotate.

This way you have object that can rotate around that center in all 360 degrees (like electrons around the core of atom).

In particular case, if you need to make it rotate on plane (like planets around the star), just make your center Kinematic and enable the axis (axes) around which your orbital object will rotate.

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

Answer by Epixam · Oct 27, 2012 at 05:18 PM

Perhaps a fix could be for you to create an empty game object at the point in which you would like to rotate around and set it as the parent of your objects transform and apply the torque to that object. When OnCollisionEnter is called destroy the empty object?

Comment
Add comment · Show 6 · 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 Nonakesh · Oct 27, 2012 at 05:31 PM 0
Share

The problem is that I want that the rigidbody continues to rotate around the point while colliding, although it should be (realistically) slowed down. Your approach would immediately stop the rotation.

avatar image Epixam · Oct 27, 2012 at 05:49 PM 0
Share

Aaah I see. Is the point you would like to rotate around static in reference to the main object or will it be changing?

avatar image Nonakesh · Oct 27, 2012 at 05:51 PM 0
Share

Unfortunately it will change... maybe even while rotating!

avatar image Epixam · Oct 27, 2012 at 05:54 PM 0
Share

Do you always have the exact location of this point that you would like to rotate around?

avatar image Nonakesh · Oct 27, 2012 at 05:58 PM 0
Share

Yes, but as I said it can change its position.

Show more comments
avatar image
-2

Answer by Montraydavis · Oct 27, 2012 at 03:00 PM

Set the contraints on the Rigidbody ( freeze pos(x,y,z) rot(x,z) ) and AddForce from the Docs. -- http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html

PS: Alter the settings to your requirements.

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 Nonakesh · Oct 27, 2012 at 03:05 PM 1
Share

Have you really read the question? $$anonymous$$aybe I haven't formulated it well enough... I want that the rigidbody still reacts to collisions with other rigidbodies.

Also the whole point of this question is that I want to rotate the rigidbody around a point that is NOT the center point, so constraining the rigidbody would make everything worse...

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

15 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

Related Questions

Add Force to the right of the rigidbody, not right of the screen 1 Answer

Rotation problem with spawning bullet 2 Answers

How to have a cube to fall on fixed rotation? 1 Answer

How to make a ball capable of rolling around a loop the loop? 1 Answer

Make object tip over 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