- Home /
Question by
NatePrograming · Feb 04 at 10:04 AM ·
hinge joint
How do i make a script that drags a hinge joint object
i am trying to make a ragdoll game and i need to make this code drag a hinge joint ragdoll using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Drag : MonoBehaviour
{
Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
private void OnMouseDrag()
{
Vector3 mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z + transform.position.z);
Vector3 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);
transform.position = objPosition;
rb.isKinematic = true;
}
private void OnMouseUp()
{
rb.isKinematic = false;
}
}
this is the ragdoll in the library
[1]: /storage/temp/192159-screenshot-357.png
i am new to unity and would appreciate any help that you can provide, thank you
screenshot-357.png
(12.1 kB)
Comment
Your answer
Follow this Question
Related Questions
Rebounding Hinge Joint 2D 0 Answers
Actual name of target velocity? 2 Answers
Is there any way I can move a hinge joint around the stage? 0 Answers
Hinge Joint Jumpy 1 Answer
How to edit Hinge Joint Target Position in a script? 1 Answer