Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by dorpeleg · Apr 01, 2013 at 09:59 PM · physicsrigidbodyaddforceballjoint

Ball physics help

Hello everyone.

I'm trying to make a simulation of an object but I'm having a lot of trouble getting it working.

object

Let me explain:

Think of the black as a transparent plastic ball.

In the center of the ball, there is a cylinder which is connected to the ball on both sides (blue).

On the center of the cylinder, there is a box (green) with a hole for the cylinder to go trough.

Most of the box's weight is at it's buttom (red).

Here is how the ball needs to behave:

When going forward, the ball needs to rotate forward while the box needs to stay the same (because the weight keeps it down).

Same thing for going back (ball rotates back and box stays).

Conclusion:

Because I'm trying to simulate it, it needs to be done with physics and not animation or anything like that.

I tried playing around with rigidbodys and joints but without getting the desired results.

Any help on how to build this object and how to move it around will be really appreciated.

Thanks!

Comment
Add comment · Show 7
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 Polinator · Apr 01, 2013 at 10:14 PM 0
Share

Can't you just restrict the rotation of the blue cylinder and green box in the rigidbody constraints? Unless there is something else you aren't saying that you need that should keep the box in the center and the ball can go wherever it wants.

You might have to play around with the child/parenting of the objects, to let the box take the balls position, but the box shouldn't rotate with it.

avatar image dorpeleg · Apr 01, 2013 at 10:23 PM 0
Share

The box needs to be able to rotate but it's weight will keep it almost not moving.

Remember, this is a simulation, I'm trying to get it to be as real as possible.

avatar image dorpeleg · Apr 02, 2013 at 01:40 PM 0
Share

Let me try to break it down to parts.

Right now I have a ball.

The ball has a rigidbody with sphere collider.

I'm trying to use this code to move it:

 void FixedUpdate() {
         if(Input.GetButton("BallForward")){
             power = 10
         rigidbody.AddRelativeForce(transform.forward * power);
         }    
         if(Input.GetButton("BallBackward")){
             power = -10;
         rigidbody.AddRelativeForce(transform.forward * power);
         }    
     }

But for some reason, the ball starts moving forward and then its going back (while I still have the key pressed) like something is trying to hold it in place.

avatar image dorpeleg · Apr 02, 2013 at 02:24 PM 0
Share

Ok, nvm I solved the problem.

It was very weird.

If the script was on the object, it didn't work.

The second I put the script on a different object, it worked :S

Now for another part:

I managed to attached the center box(green) to the bar in the middle(blue) but I'm not sure what's the best way to create the weight.

avatar image Polinator · Apr 02, 2013 at 03:36 PM 0
Share

Can you put an empty/non-rendered game object on the bottom of the box and add mass? Connect it the same way you did with the box to bar.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ExpiredIndexCard · Apr 01, 2013 at 10:55 PM

Make the square kinematic. If that doesnt work, then use a Physic Material. Add the physic material to your ball and square. Maybe increase the mass of the square. If you need help with physic materials, check this out: http://unity3d.com/learn/tutorials/modules/beginner/physics/assignments/bouncing-ball http://docs.unity3d.com/Documentation/Components/class-PhysicMaterial.html

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
0

Answer by Owen-Reynolds · Apr 06, 2013 at 03:35 PM

To put a "weight" on the bottom of the interior cube without a new object, can use rigidbody.centerOfMass = new Vector3(0,-3,0); The center of mass doesn't even have to be inside the object. The lower it is, the more the square will stay up like a punching bag clown.

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 dorpeleg · Apr 06, 2013 at 03:51 PM 0
Share

Thanks, that's good to know.

I still have the problem of the object swinging from side to side (when I'm pressing any keys).

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

12 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

Related Questions

Ball Rotating Help 0 Answers

How could I make a bouncy object move mostly along the Z axis? 1 Answer

need tutorials for rigidbody.Addforce 1 Answer

How to make rigidbodies on each side of a cube fall towards the cube? [multiple gravity / addForce] 0 Answers

Rigidbody Sliding UP Incline 0 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