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 user-10650 (google) · Apr 14, 2011 at 07:28 PM · jointcreateaddcomponentconfigurablejoint

Joints Configured from Script do not work properly? $20 reward

I desperately need to be able to create joints via script. Currently I add and then set them up and they sort of work but something is clearly wrong, Motion and Angular Motion that are supposed to be locked are not locked, PositionSpring can only add a weak amount of force and position damper actually reduces that force without actually adding any damper.

Duplicates of these assemblies actually get progressively worse. I've tried setting .active to false just before and after .AddComponent with no effect. I have the same problem instantiating prefabs with joints, and creating joints via the editor with the game running.

Is there no way to add a Configurable Joint with the game running?

$20 Bounty for a solution to this.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jean-Fabre · Jan 05, 2012 at 04:12 PM

Hi,

Totally feasible. I made a demo last year with an excavator fully scripted, building joints and setting them up on the fly.

http://www.fabrejean.net/projects/excavator/

Bye,

Jean

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 taters · May 25, 2011 at 02:29 PM

I'm actually having a similar issue, but I have got as far as adding the joint. It's just the drive settings etc just dont 'stick'.

Here is my code that adds a config joint o.k. It's just that setting the angularXDrive and spring dont seem to do anything.

You can download my test scene here, it may be a good starting point. At least the joints are being added!

If you figure a way to make the angularXDrive and spring stick when done through script, please let me know!!

Dave

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 dear_gamemaster · Nov 28, 2011 at 05:36 AM

I do it like this (in a collision example):

function OnTriggerEnter(collision : Collider) {

     var joint : FixedJoint = gameObject.AddComponent(FixedJoint);
     joint.connectedBody = collision.gameObject.rigidbody;
     joint.breakForce = 250;
     joint.breakTorque = 250;
 

}

Don't create and add a joint from scratch, let AddComponent(FixedJoint) create it and return it, then define it's values and there you are. In this example, it's working with a fixed joint, but I tested it out and it's working with any of the predefined ones.

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 inum76 · Oct 07, 2015 at 01:19 AM

I found while using scrips, C#, The Rigidbody falls asleep. You need to wake it up within the script during each update. It is a bad idea to mess with a Quaternion directly. You should set XYZ in Euler angles with a vector3. public Vector3 Vec1; Then you set your Quaternion with it, this way: private Quaternion QVec1; QVec1 = Quaternion.Euler (Vec1); QVec1 would be your set Quaternion with the angles you wish it to have. This is my vid on the subject you ask about, if you wish to check it out. Link: ConfigurableJointScript 1 The vid tells how to properly set TargetRotation within a script, and have it work! Hope this helps. Oh' you can keep you $20 if it does help you. :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

controlling the target rotation of a configurable joint via input? 1 Answer

Difference between creating Configurable Joint in code and creating the same type of Joint in script 1 Answer

Dynamically create GUIText from script. 2 Answers

Attaching a Hinge Joint upon colliding with a rigidbody. 1 Answer

Joint: Swing & Twist? 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