Hi
I’m trying to make a snake game. What I want to do is to spawn a new segment of the snake when it eats a instantiated prefab that I call dot and then make that segment a child of the first segment. The segments also have to spawn at a longer distance from the first segment the longer the snake gets.
This is the code that I have wrote.
#pragma strict
function Start () {
}
var tailend : Vector3;
var zaxis : int;
var tailsegment : GameObject;
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.name == "dot(Clone)"){
tailend = Vector3(0,0,zaxis-1);
var Instance : GameObject = Instantiate(tailsegment, tailend, transform.rotation);
Instance.transform.parent = transform;
}}
When the snake eats the dot nothing happens. I would be very thankful if someone could read it and tell me what i’m doing wrong.
Are you going to be texturing your snakes so they look realistic or just keep them as blocks?
– MeltdownWas just wondering cos we made a game called Snake Showdown for Android and iOS and getting a textured snake working was a %($@%%$* nightmare, the guy working on it ended up using procedural mesh generation. Just saying it is certainly not easy but if you keep it to blocks you'll be ok.
– Meltdown