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 shaibam · Jul 02, 2015 at 03:50 PM · 2d-physicsdistancedragjointrope

keeping constant "Distance Joint 2d"

I am using the "distance Joint 2d" component for dragging an object. it seems that although the "Max distance Only" check box is selected if moving fast the parent object , the child object distance grows to be more than defined in the "Distance" param.

why?

//Parent movement code

using UnityEngine; using System.Collections;

public class moveDude1 : MonoBehaviour { Vector2 current_position; // Use this for initialization void Start () { current_position = transform.position; }

 // Update is called once per frame
 void Update () {
     if (Input.GetKey ("right")) {
         //transform.Translate(1,0,0);
         transform.position = new Vector3 (transform.position.x + 1, current_position.y, transform.position.z);
     } else if (Input.GetKey ("left")) {
         //transform.Translate(-1,0,0);
         transform.position = new Vector3 (transform.position.x - 1, current_position.y, transform.position.z);
         //} else {
         //    transform.position = new Vector3 (transform.position.x, current_position.y, transform.position.z);
     }
     
 }

}

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by shaibam · Jul 05, 2015 at 01:33 PM

Before you answered I resolved to working with a 2 hinge joints instead of the DistanceJoint. It seems to do the job, though it might not be intended for it.

anyway I've later tried your solution, and since I didn't want to touch the project settings. your suggestion for applying force instead of the transform method really helped.

thank you very much

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
2

Answer by KevinCodes4Food · Jul 02, 2015 at 06:35 PM

I implement a joint "chain" in a pickup truck game, and had similar issues with joints moving beyond set bounds, or even breaking when set to infinite break strength.

I used three solutions to keep joints within assigned attachment space.

  1. First, I increased the physics time step by decreasing the Project Settings -> Time -> Fixed Timestep. For my game, 50 to 100 updates per second worked well (0.02 to 0.01). But be sure to watch for performance issues if set too high.

  2. I increased the physics Solver Interation Count in Project Settings -> Physics. Around 10 seemed to work well, but if you have lots of collisions, springs, joints, etc. this can create performance issues.

  3. I made sure rigidbody objects attached to joints were only updated with force or rigidbody updates. Instead of setting the position directly in the transform as you are in your code, try applying a force or using Rigidbody.MovePosition

Hope that helps!

Kevin

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Can you use a Distance Joint without the "pulling"? 0 Answers

Only make connected rigidbody move when distance is changed on 2d joint 0 Answers

Rope Mechanics for Grapple; Climbing and Swinging 2 Answers

programmatically added SliderJoint2D not respected 0 Answers

Joints 2D, rope 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