Hello, i’m actually making a Flappy Bird clone, and when i started to work on the menu and reloaded the main game scene, something strange happened.
When i pressed the play button, my character instantly moved under the terrain at 9xxx position( I don’ t remember the exact one).
I think this is something related to the physics engine, because if i remove the Rigidbody component attached to my player, the player doesn’t move, and the exact thing happen if i remove my Sphere Motion script.
This is my Sphere Motion script text
#pragma strict
var force:int;
static var animate:boolean=true;
static var canDie:boolean=true;
static var canMove:boolean=true;
static var points:int;
static var record:int;
function Start(){
force=force*1000;
gameObject.rigidbody.AddForce(Vector3(0,force,0));
}
function Update () {
record=PlayerPrefs.GetInt("record");
if (animate){
animation.Play("dragon_idle");
}
if (Input.GetKeyDown("space")){
//if((Input.touchCount>0) && (Input.GetTouch(0).phase==TouchPhase.Began)) {
if (canMove){
animation.Stop();
animation.CrossFade("dragon_panic");
gameObject.rigidbody.AddForce(Vector3(0,force,0));
}
}
}
function OnCollisionEnter(col:Collision){
if(col.gameObject.tag=="Obstacle"){
Inventory.move=0;
Inventory.canInst=false;
SphereMotion.animate=false;
if (canDie){
gameObject.animation.Play("dragon_die");
Debug.Log("Collision");
canMove=false;
canDie=false;
}
}
}
Thanks to everyone for the answer, and may a get an explaination for what is happening, for avoiding me to do the same error?