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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by RichCoggin · Apr 07, 2013 at 11:15 AM · physicscharacter

Attaching an object to a controllable rolling ball...

Hey guys,

I'm a newbie to unity and trying to work out how I can create a controllable rolling ball which has another object (like a box) move with it. The box would be placed directly above the ball and turn in the same directon when the ball is moved around. To add to this, the box would react to movement as if it were attached to the centre of the ball; so when the ball moves forward, for example, the box would slightly move back, because it is attached to the pivot point of the ball and is reacting to the forward force. The, when the ball slows down and comes to a hauls, the box then springs back to the centre position above the ball; as it it attached by a spring.

I have been playing with rolling ball demo on the unity page which is cool. Now I just want to see if I can add this box object to it. My initial thought is to create a.n object which is the child of the ball and attach the box to that. Then, add a script to the box to understand the action of the ball. I'm assuming there are various ways to approach this, but I'd love to hear your thoughts on a script/s and where and how to attach these to the given objects.

Thanks in advance for any help.

Rich

I hope that this makes sense!

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
Best Answer

Answer by mhtraylor · Apr 07, 2013 at 12:54 PM

Try using a Spring Joint attached to the box: http://docs.unity3d.com/Documentation/Manual/Physics.html. For instance, you could create an empty GameObject at the desired target height above the ball, set in script to always be at a position above the sphere, with an attached Rigidbody. Then set this empty object as the Connected Rigidbody of the Spring Joint that is attached to the box. You can adjust the Spring to get the desired movement.

Comment
Add comment · Show 11 · 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 RichCoggin · Apr 07, 2013 at 02:37 PM 0
Share

Thanks. I will give this a go. $$anonymous$$uch appreciated.

avatar image AlucardJay · Apr 07, 2013 at 02:49 PM 0
Share

Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base.

Here at Unity Answers, Answer means Solution, not Response.

Please watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

I have converted this to a comment for you. Also you don't have to wait for a moderator to approve a comment.

avatar image RichCoggin · Apr 07, 2013 at 06:04 PM 0
Share

$$anonymous$$y fault. Sorry.

So, just trying to work this out:

'...you could create an empty GameObject at the desired target height above the ball, set in script to always be at a position above the sphere...'

How is this done exactly. I was assu$$anonymous$$g you make the empty gameobject the child of the ball, but that's not working.

Thanks in advance.

avatar image AlucardJay · Apr 07, 2013 at 07:57 PM 0
Share

Not quite. Try this : Create an empty gameObject. Attach the following script :

 #pragma strict
 
 public var target : Transform;
 public var offsetToTarget : Vector3 = new Vector3( 0.0, 1.5, 0.0 );
 private var myTransform : Transform;
 
 function Start() 
 {
     myTransform = transform;
 }
 
 function Update() 
 {
     myTransform.position = target.position + offsetToTarget;
 }

Now in the inspector where it says target, drag and drop your Ball object. Now hit Play, and move the Ball object around. You will notice that the empty gameObject stays at the offset position (0, 1.5, 0) to the Ball object. Change the offset Vector3 to where you want the empty object to follow. That's it =]

avatar image RichCoggin · Apr 07, 2013 at 08:11 PM 0
Share

That's ace. Thanks a bunch. I have a couple of other questions if you could be so kind:

I want the object that is targeting the ball to follow the direction of ball (turn it's face to the direction the ball)

Can the object have a spring motion to give the impression that it it is see$$anonymous$$gly attached with a tight spring? So when it jumps for example, the attached object has a little bounce to it?

Again thanks in advance.

Show more comments

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

How should I make a animate fully physics based Active Ragdoll? 0 Answers

How to use character controller to push down hinge joint properly 1 Answer

Can a character collider be affected by a rigidbody collider? 0 Answers

ragdoll head stretching 0 Answers

Ground clamping a rigidbody on slope 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