Quantcast
Channel: Questions in topic: "rope"
Viewing all articles
Browse latest Browse all 194

jungle swing type game ...?

$
0
0
Hi All, I am doing a simulation i.e of type jungle swing. I used hinge joints for the rope creation and top part is there to hold the rope. Below I attached both web player and code. I am about to do a jungle swing(Iphone application) type of thing. I am unable to instantiate the rope and all for the next position.Go through the thing which I did, and help me to complete it. please forward me to complete it.![alt text][1] Thanx in advance... using UnityEngine; using System.Collections; public class hingeCreation : MonoBehaviour { public GameObject sphere,cylinder;//sphere is for representation of the boy to swing, cylinder is for rope bool flag =true; public float x,y,z;// for initial rotation of the rope Vector3 scale;//for creating certain length rope public static bool stopScale; // Use this for initialization void Start () { //x=270.0f; //y=0.0f; //z=0.0f; } // Update is called once per frame void Update () { if(Input.GetMouseButtonDown(0)){ Destroy(this.gameObject.hingeJoint); // to be implemented for inactivating rope for a while and creaing at a new position this.gameObject.SetActive(false); //Destroy(this.gameObject.transform.parent); } if(!stopScale){ scale = cylinder.transform.localScale; scale.y += 0.09f; cylinder.transform.localScale = scale; } } void OnCollisionEnter(Collision col){ stopScale = true; print(col.gameObject.name); if(col.gameObject.name == "collider" && flag == true){ HingeJoint sphere = this.gameObject.AddComponent("HingeJoint") as HingeJoint; // creating the joint at the collision point this.gameObject.hingeJoint.breakForce = 100000000.0f; this.gameObject.hingeJoint.breakTorque = 1000000.0f; StartCoroutine("create",0.1f); flag = false; } } IEnumerator create(float t){ yield return new WaitForSeconds(t); this.gameObject.rigidbody.useGravity = true; //this script is attached to rope(cylinder) firstly it will have no grvity, rope has a hinge we have to use grvity sphere.gameObject.GetComponent().connectedBody = this.gameObject.rigidbody; this.transform.parent.parent.gameObject.transform.eulerAngles = new Vector3(x,y,z); Invoke("Created",1.0f); } void Created(){ sphere.gameObject.GetComponent().tag = "Infinity";// bob and rope will connect together sphere.gameObject.GetComponent().tag = "Infinity"; sphere.gameObject.rigidbody.useGravity = true; } } [1]: /storage/temp/18986-app.jpg

Viewing all articles
Browse latest Browse all 194

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>