Is there any method that I can grab object from any point on object and drag them realistic way.
When I grab it, I want it to settle down by mass axis. Like this:
[70608-adsız.jpg|70608]
Then when it’s accelerating. It goes like this:
When I tried to do this with springjoin2D, I cant make the same behaviour like above.
Then, I did this with hinge joint but I can’t avoid this object from overlapping with other object, is there any other way to do this? or Where did I make mistake here is my script.
here I tried to achive connected anchor to follow my mouse position. Object behavior like above but with one mistake, object can overlap collision area of other object.
I understand why this problem occur:
Because I am teleporting object to mouse position so it ignores collision effect…
But I cant figure out the solution
using UnityEngine;
using System.Collections;
public class MouseJoint : MonoBehaviour {
Vector2 mousePos2D;
SpringJoint2D sj;
void Start() {
sj = gameObject.GetComponent<SpringJoint> ();
}
// Update is called once per frame
void Update () {
Vector3 mouseWorldPos3D = Camera.main.ScreenToWorldPoint (Input.mousePosition);
mousePos2D = new Vector2(mouseWorldPos3D.x, mouseWorldPos3D.y);
}
void FixedUpdate ()
{
sj.connectedAnchor = mousePos2D;
}
}
`
I thing it is very fundemental to grab object like this, and drag it physically.
I am very beginner to unity
And sorry for my bad english
`