This is rather embassising but ive forgotton how to use my own scripts a cupple of months ago i made these now ive completely forgotten how to use the second one, i was quite sure that i just needed to make a prefab for tail and connect it but ive had no luck
it just goes mental and now it dosent even instantiate the tail segment, its possible that the scripts been broken but i have a perfectly working build on my phone. I know this is a big ask but dose anyone know how to make this have the desired effect?(how to use it) this is an old web build of it working: hear
and this is the script for movement, this one works i just put it onto a cube that had a chiled called “Defunk”:
private var Inputing : Vector2;
private var oldpos : Vector3;
private var curpos = Vector3;
//static var ismove = false;
function start ()
{
if(Application.platform == RuntimePlatform.Android)
{
Inputing = (Input.GetTouch(0).position);
}
else
{
Inputing = Input.mousePosition;
}
}
function Update ()
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray,hit))
{
var point: Vector3 = hit.point;
point.y = 1.5;
//print("Z="+point.z+",X="+point.x+",Y="+point.y);
transform.LookAt(point);
transform.position = (point);//this is the cause i think
}
}
and this is the script that controlls everything else? but i cant get it to work correctly:
var sizeY = 20;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == "food")
{
//food starts hear
var foodeat = collision.gameObject;
Destroy (foodeat);
var position : Vector3 = Vector3(Random.Range(-sizeX, sizeX), 1, Random.Range(-sizeY, sizeY));
Instantiate(food, position, Quaternion.identity);
//tail starts hear
var inspont = tail.transform.Find("Defunk");// finds Defunk
var tailpos = inspont.transform.position; //tail position identifide
var tailsegmade = Instantiate(tailsegment,tailpos , Quaternion.identity); //create segment at tail position
var tailsegridge = tail.rigidbody; // tailsegridge is tails rigidbody
tailsegmade.hingeJoint.connectedBody = tailsegridge; //conects tailsegment to tail
tail = tailsegmade; //tail now is tailsegment
}
//else if(collision.gameObject.tag == "edge")
//{
//Destroy (gameObject);
//}
//else if(collision.gameObject.tag == "Tail")
//{
//Destroy (gameObject);
//}
}
Sorry for this but i just cant figure it out.