• 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 H3core · Dec 30, 2012 at 09:36 AM · 2dphysicscarjointwheel

2D Joint/Wheel Question

Hi, Im currently working on a 2D game and i need to snap wheels on an object, i tried using various kinds of joints, yet they never seem to stick in place and keep moving a certain distance from the main object. Basically something like a skateboard and 2 wheels.

Is there something else other than joints im supposed to be using rather than joints?

sorry for the noob question :)

thnx for ur time Unity Community :)

Btw i intend to use torque on the wheels for motion, if thats not a great idea and/or should just stick to apply force, your guidance would be appreciated :)

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 Fattie · Dec 30, 2012 at 11:35 AM

Just to begin with:

When you attach one object to another.

For example, you have a spaceship and you want to attach a wing. Or you have a truck and you want to attach a container on the back. Or you have a player character and you want to attach a backpack.

Simply - you need to use the parent-child relationship

Note that the parent goes with the "transform".

So in short, you would do something like this:

One -- make a new "wheel unit". Use "Instantiate" to do this. if you do not know about Instantiate read the doco, or ask a new question, or search.

 var newWheelUnity:GameObject;
 newWheelUnit = Instantiate( myModelWheenUnit );

You now have a beautiful new wheel unit.

So. Now you must make it that your VEHICLE is the PARENT of that new wheel unit. Don't forget, you have to use "transform" for this.

So first set all the other stuff for newWheelUnit ...

 newWheelUnit.name = "special name";
 newWheelUnit.layer = 13;
 etc etc

Now set the parent ..

 newWheelUnity.transform.parent = yourCar.transform;

Now you have to set the position of that child. USe localPosition to do that.

 newWheelUnity.transform.localPosition = Vector3(0,0,0);

it won't actually be "0,0,0" 0 it will be the actual position of the wheel on the car. Since it works in meters, it might be something like "1.25, -0.835, 0"

First you have to master all this so that you can easily "add parts" to something else

Once you get really good at this, you have to look in to the whole topic of making wheels turn, etc. That is a hugely separate topic and you will need to do a lot of searching and questioning. Good luck!

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 H3core · Dec 31, 2012 at 05:28 PM 0
Share

Thank you, that did solve the problem even though i was attempting a similar approach with parenting objects in the editor, dont know why exactly it just wouldn't work on these, others seem to stick together just fine, probably missing another trick as i am fairly a noob at Unity :)

But there is another issue now hope that you can quickly assist me, since the objects have regular box and sphere colliders and rigid bodies to drop with gravity, while un-parented they just tend to drop and rest upon each other which is expected and just fine... But upon parenting, as the whole rig drops to the ground it now does a bounce, and if i wait till it hits the floor again it does an even bigger bounce no matter how close i place the object to the grond to avoid this...... What's causing this strange bounce? I dont have any materials set to simulate a bounce or rubbery environment.

Thanks once again :)

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

in Unity 3.5.7 car starts to shake 0 Answers

Square wheels 4 Answers

Unity 2D Car Side Scroller question. 1 Answer

Car physics problem 0 Answers

2D Car Help 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