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 question was closed Feb 13 at 06:24 PM by alee26 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by alee26 · Aug 05, 2012 at 10:45 PM · rigidbodyjointlockhingelocked

Why Hinge Joint Component locks rigidbody transform?

when i use the code below, my rigidbody "myObj" requires a "Hinge Joint Component" attached to itself and then it locks on the scene and i can't control it with the control keys? Why this occurs? Please help... Note: I don't think it's because of this code, when i add Hinge Joint Component to myObj without using the script the same thing happens again. i think there must be something else that i miss. Here is the code:

using UnityEngine;

using System.Collections;

public class AttachControl : MonoBehaviour {

// Use this for initialization

    void Start ()

{

} // Update is called once per frame

    void Update ()

{

}

void OnCollisionStay(Collision collision) {

Transform myTarget = transform.Find("/myObj/myObjChild");

    float px = myTarget.transform.position.x;

    float py = myTarget.transform.position.y;

    float pz = myTarget.transform.position.z;

 

GameObject attachedObj = GameObject.Find("attachedObj");

bool attachKey = Input.GetKey (KeyCode.F);

    if (Input.GetButtonDown("attachKey")) { 
 
    attachedObj.rigidbody.position = new Vector3(px,py,pz);
 
    hingeJoint.connectedBody = attachedObj.rigidbody;
 
    hingeJoint.anchor = new Vector3(px,py,pz);
 

}

    else if (Input.GetButtonDown("attachKey")) {
 
    hingeJoint.connectedBody = null;

} } }

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

  • Sort: 
avatar image
0
Best Answer

Answer by alee26 · Aug 26, 2012 at 11:46 AM

The solution has two case. First is, if you need a joint in a triggered condition else then collision, define the condition separately (like closing objects coordinates). Second, if you need the joint to be created after the first condition , use a script like "gameObject.AddComponent();".

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

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Hinge Joints, distance to connected body 1 Answer

How can i change HingeJoint's axis from code? 0 Answers

Hinge Joint? Unconstrained. 1 Answer

"Gluing" pieces together for a breakable object with springs 1 Answer

Joints vs Mass 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