Creating a rope in 3D for grappling
Hello Everyone
I'm trying to create a rope for a grappling gun in a 3D game. I Created the hook, travelling from target to Hook launcher without a problem, but the function creating prefab with joint never works.
I'm trying to create a function which woul create nodes from the hooklauncher (player's hand) attached to the hook first then the last node created. That way, the rope can virtualy be extra long.
I used partialy the script from this tutorial : link text
But it never work whatever modification I'm bringing. So I hope someone can help me
Thank you very much
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class RopeScript : MonoBehaviour
 {
 
 
     public Vector3 DestinationHook;
 
 
     public float HookSpeed = 1f;
 
 
 
     public GameObject NodePrefab;
 
     public GameObject lastNode;
 
 
     public bool HookOnDestination;
 
 
     public GameObject Target;
 
     public GameObject HookLauncher;
 
     public GameObject FirstNode;
 
 
 
     public bool Fired;
 
     public bool NodeCreation;
 
     public bool done = false;
 
 
     public float TimeCreation;
 
     public float TimeBase = 0.0001f;
 
     public int NumberOfNode;
 
 
 
     // Use this for initialization
     void Start()
     {
 
         //TimeCreation = TimeBase;
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         //TimeCreation -= Time.deltaTime;
 
         if ((NodeCreation == true))
         {
             CreateNode();
             //TimeCreation = TimeBase;
         }
         if (Fired == true)
         {
             transform.position = Vector3.MoveTowards(transform.position, Target.transform.position, HookSpeed);
             NodeCreation = true;   
         }
         else
         {
             transform.position = Vector3.MoveTowards(transform.position, HookLauncher.transform.position, HookSpeed);
             NodeCreation = false;
         }
         
         if (transform.position == Target.transform.position)
         {
             NodeCreation = false;
             
         } 
 
     }
 
     public void CreateNode()
     {
 
        if (NumberOfNode == 0)
         {
 
            GameObject go = (GameObject)Instantiate(NodePrefab, transform.position, Quaternion.identity);
 
             go.transform.SetParent(transform);
 
             HookLauncher.GetComponent<CharacterJoint>().connectedBody = go.GetComponent<Rigidbody>();
 
             lastNode = go;
 
         }
         else
         {
             GameObject go = (GameObject)Instantiate(NodePrefab, transform.position, Quaternion.identity);
 
             go.transform.SetParent(transform);
 
             lastNode.GetComponent<CharacterJoint>().connectedBody = go.GetComponent<Rigidbody>();
 
             lastNode = go;
         }
 
       
 
     }
 
 }
Your answer
 
 
             Follow this Question
Related Questions
[Problem] Trying to create a rope for a grappling hook 1 Answer
Instantiating random sprites, with no space between them? 0 Answers
Is there any good sample code for shooting a projectile and collision detection? 0 Answers
GameObjects pass through each other when they are connected with configurable joint 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                