Question by
Crazeus · Nov 02, 2015 at 10:26 PM ·
c#hingejointgrappling gun
Connecting player to a hinge joint moves him across the map.
So I've been trying to make a simple grappling hook where you can just swing from a point to start things off. I thought hinge joints would be the perfect choice for this since it's a set distance between the two joined bodies. The problem is when I use hingejoint.connectbody to connect my player to the grapple point it moves my player to the opposite side of the grapple point. Here's the script I use: using UnityEngine; using System.Collections;
public class GrapplePoint : MonoBehaviour {
private HingeJoint hj;
public Rigidbody playerRB;
void Start () {
hj = GetComponent<HingeJoint>();
}
void OnCollisionEnter (Collision col) {
if (col.gameObject.tag == "Bullet")
{
hj.connectedBody = playerRB;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Help with coding crane 0 Answers
Children of a hingejoint not colliding with parent's mesh when connectedBody is assigned 1 Answer
Rotate a hinge joint on its own 0 Answers
Draggable doors problem 0 Answers