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 Clockwork Fromage · Oct 14, 2011 at 05:26 AM · jointsconnectedbody

changing the connectedBody of a joint on another GO

i've been at this for 2 hours atleast and i cant see what im missing , i checked the syntax and the references but still it just wont work

i need to set the connectedBody of a joint on another gameObject , this is my code

 function Update (){
 
 if(Input.GetButtonDown("p1pushl")){buttondown = true;}
 if(Input.GetButtonUp("p1pushl")){buttondown = false;
 StartCoroutine("dropgun");
 }}
 
 function OnCollisionEnter (c : Collision){
 if(buttondown == true){
 //if(!joint.FixedJoint&& !handsrfree){
 var joint = c.gameObject.AddComponent(FixedJoint);//var joint = 
 joint.connectedBody=transform.rigidbody;
 Debug.Log(joint.connectedBody);
 }}
Comment
Add comment · Show 4
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 syclamoth · Oct 14, 2011 at 06:27 AM 0
Share

What is the exact error you are getting? Try specifically setting the type of the 'var joint' line- so that it goes more like this

 var joint : FixedJoint = c.gameObject.AddComponent(FixedJoint);

(The fact that it is possible to do this at all without explicitly stating the type is part of what annoys me about javascript...)

avatar image Clockwork Fromage · Oct 14, 2011 at 06:44 AM 0
Share

just tried and still nothing , the debug log always returns null and the object is always remains connected to the scene

avatar image Clockwork Fromage · Oct 14, 2011 at 07:47 PM 0
Share

the problem is not adding the component to the object , that works just fine , what dosent work is changing afterward , this line simply will not work no matter how i phrase it

joint.connectedBody=transform.rigidbody;

ive tried every single way to reference the rigidibody of the GO the script is in and none work , so i tried changing the reference used this way

c.gameObject.AddComponent(FixedJoint); var joint = c.gameObject.GetComponent(FixedJoint); joint.connectedBody=transform.rigidbody;

and still the object gets its joint and its connectedbody remains null

ive tried every permutation i can think of and made sure all capitalization was correct , can anyone see my mistake ?

avatar image Clockwork Fromage · Oct 14, 2011 at 11:09 PM 0
Share

dosent anyone know this ? every way ive tried to add the joint works fine but none of ways ive tried to do change the connected body will work

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to get the World position of a connectedAnchor? (2d) 1 Answer

Problems with sending multiple raycasts at once 1 Answer

How do you find a Joint from its connectedBody? 1 Answer

Tie objects together 5 Answers

Locomotion and Joints 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