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 grogzgr · Jan 06, 2015 at 12:28 PM · dragslidermouse-dragmultiple objects

Pulling multiple objects

Since I am not getting responses, even requests for clarification, I guess I did a bad job asking the question. Any help, even a request to clarify would be greatly appreciated. For background I am doing this abacus to help out a friend who is doing his Masters in Education. I also wanted a project that I could learn Unity with. This simple app seemed like a great place to start.

I am attempting to create an abacus. I have a script that will drag a bead around just nicely. When the bead that I am dragging around comes into contact with another bead they both move but at a snails pace. How do I get the combined beads to continue to move at the same speed as a single bead?

I am using RigidBody2D, and BoxCollider2D along with a SliderJoint2D on each of the beads. The SliderJoint2D starts off not having a Connected Rigid Body.

Here is the movement script that I have been using.

 using UnityEngine;
 using System.Collections;
 
 public class DragBead2 : MonoBehaviour {
 
     private SliderJoint2D slider;
 
     void Awake()
     {
         // "slider" is the SliderJoint2D component that I added to my object
         slider = this.gameObject.GetComponent<SliderJoint2D>();
 
         // I want the anchor position to start at the object's position
         slider.connectedAnchor = gameObject.transform.position;
     }
     
     void OnMouseDown()
     {
         // I'm reactivating the SliderJoint2D component each time I'm clicking on my object 
         // because I'm disabling it after I'm releasing the mouse click so it will fly in 
         // the direction i was moving my mouse
         slider.enabled = true;
     }
     
     void OnMouseDrag()        
     {
         if (slider.enabled == true) 
         {
             // Getting cursor position
             Vector2 cursorPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
             
             // The anchor get's cursor's position
             slider.connectedAnchor = cursorPosition;              
         }
     }
     
     void OnMouseUp()        
     {
         // Disabling the slider component
         slider.enabled = false;
     }
 }

Any help is greatly appreciated. As a side note this script is a modified version of a script I found on here (sorry but I cannot remember whose it was originally).

Thanks in advance.

Comment
Add comment · Show 2
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 grogzgr · Jan 12, 2015 at 01:01 AM 0
Share

In addition to using SliderJoint2D, I have tried SpringJoint2D and DistanceJoint2D all of which result in similar behavior. The collision detection on the RigidBody2D is set to Continuous and Interpolated. I noticed that moving multiple beads with collision detection set to Discrete is a little better (they move faster), but at this point the collision detection no longer respects the bead boundries and the beads can be forced to overlap and even go through one another. Some background: The Soroban abacus that I am trying to model has 4 beads below the count bar on the bottom. If I grab the top bead, the movement is fine, I can move it up and down without issue. If I was to grab the second bead from the top and move it up, push the top bead at the same time, the movement slows down to a crawl. If I was to grab the third bead from the top and move it up, pushing to other two beads up, the movement is even slower. Pushing all four beads up, by grabbing the bottom bead, is not even possible, they just dont move.

avatar image rageingnonsense · Apr 14, 2015 at 04:05 PM 0
Share

I'm not too familiar with this aspect of the API, but if you are using physics to move the beads, they might be too heavy (check the mass of the rigidbodies)?

That being said, it might be easier to manipulate transforms directly, and not use the physics system at all.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to click and drag Game Objects? 2 Answers

DragRigidbody behavior attached to multiple rigid bodies causes problems 1 Answer

I'm not sure how to approach this. 2 Answers

Collision with object using MouseDrag 1 Answer

Drag GameObject with mouse in just one axis 2 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