- Home /
Question by
guyporatmail · Mar 19, 2021 at 01:01 PM ·
fixedjoint
FixedJoint seems glitchy
I'm trying to use FixedJoint to implement a grabbing system (Similar to portal) and for some reason, it seems glitchy. This is a video of it: https://vimeo.com/526118995 This is my code right now:
public class Grabbable : MonoBehaviour
{
public Transform playerGrabDest;
public Rigidbody playerGrabRigid;
public void OnMouseDown()
{
if (Mathf.Abs(Vector3.Distance(transform.position, playerGrabDest.position)) < 3)
{
transform.position = playerGrabDest.position;
gameObject.AddComponent<FixedJoint>();
GetComponent<FixedJoint>().connectedBody = playerGrabRigid;
GetComponent<FixedJoint>().breakForce = 10000;
}
}
private void OnMouseUp()
{
Object.Destroy(GetComponent<FixedJoint>());
}
}
Comment
Your answer
Follow this Question
Related Questions
FixedJoints wiggling when too many are put together? 1 Answer
How do I connect FixedJoints on collision 1 Answer
How do I make a fixed RigidBody always face the direction of the RigidBody it is fixed to (Unity2D) 0 Answers
ridgid bodies of different mass 3 Answers
RigidBody character wont swing? 0 Answers