I create a rope with hinge joints and parent the player to the individual segment of the rope and add velocity to transform.up on the player which makes him climb the rope perfectly fine.
I then created a script to create the rope in script and add it to the game world with specific variables. When I parent the player to those rope segments it does not work at all. It just gets him stuck and kinda moves left and right a little but. I have checked and the game objects are set up exactly the same for both the script made rope and the conventionally made rope. pictures and script below.
using UnityEngine;
using System.Collections;
public class ropeMaker : MonoBehaviour {
public float length = 10;
public GameObject ropeObject;
public GameObject[] ropeArray;
public float initialSwing;
//public bool hinged = true;
// Use this for initialization
void Start () {
for(int i = 0; i < length; i++)
{
//GameObject segment = (GameObject)Instantiate(ropeObject, new Vector3(0,-0.5f*i,0) + transform.position, transform.rotation);
ropeArray _= (GameObject)Instantiate(ropeObject, new Vector3(0,-0.5f*i,0) + transform.position, transform.rotation);[25545-screen+shot+2014-04-21+at+5.00.20+pm.png*_</em></em></em></em></em>|25545]_
_ //ropeArray*.name = "Segment "+i;_
_ if (i==0){_
_ ropeArray.rigidbody2D.isKinematic = true;*_
* }else{*
_ ropeArray*.rigidbody2D.isKinematic = false;*_
* HingeJoint2D tempHinge = ropeArray[i-1].AddComponent();*
_ tempHinge.connectedBody = ropeArray*.rigidbody2D;
tempHinge.anchor = new Vector2(0,-0.25f);
tempHinge.connectedAnchor = new Vector2(0,0.25f);*_
* }*
* if (i==length-1){*
ropeArray_.rigidbody2D.velocity = transform.rightinitialSwing;
}
ropeArray.transform.parent = gameObject.transform.parent;*_
* }*
* }*
}
CONVENTIONALLY MADE ROPE
[25546-screen+shot+2014-04-21+at+4.58.59+pm.png|25546]
SCRIPT MADE ROPE
[25545-screen+shot+2014-04-21+at+5.00.20+pm.png*|25545]*
*
*