Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Duplicate Object, by dragging? (SporeCreatureCreator Like)

$
0
0
**Ok so this question, it's weird to explain but i will do my best:** I am doing some kind of "Spore Creature Creator", and I have the "Spine" of the creature (Simple cylinders one behind the other), at the moment each cylinder has a drag and drop script and they are conected by joints so i can move and pose them freely with my mouse:) The next thing I have is an "arrow" object (triangle in top of a square) at the two ends of the spine. Here is the question: How can I tell unity, that when I drag this arrow away from the spine end, a clone of this spine end appears next to the previous one (like adding an extra vertebrae), and when i drag it in the oposite direction, cylinders start to disapear. I made this drawing to explain: ![alt text][1] An here is the script I use to drag the cylinders freely in the scene, it's useful: using UnityEngine; using System.Collections; [RequireComponent(typeof(CapsuleCollider))] public class CyllinderDrag : MonoBehaviour { private Vector3 screenPoint; private Vector3 offset; void OnMouseDown() { screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position); offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); } void OnMouseDrag() { Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint)+offset; transform.position = curPosition; } } [1]: /storage/temp/28580-spine+creator.jpg

Viewing all articles
Browse latest Browse all 508

Trending Articles