problems in game play scene

I am making a duck type run game similar on chiken ninja. but i have been having a little trouble geting all the aims correct.

use this and enjoy …
/*
Script Name : MenuScreen

…*/

var bg_texure : Texture2D;
var credit_screen : Texture2D;
var settings_bg : Texture2D;
var enable_tex : Texture2D;
var disable_tex : Texture2D;
var back_button : Texture2D;
var about_screen :Texture2D;
var about_text : Texture2D;
var about_text1 : Texture2D;

var sw : float;
var sh : float;
var volumebar : float;
var scrollPosition : Vector2;

var isMain_menu : boolean;
var isAbout_screen : boolean;
var isCredit_Screen : boolean;
var isSetting_screen : boolean;

var mySkin : GUISkin;

var bg_sound :GameObject;

// Internal variables for managing touches and drags
private var selected : int= -1;
private var scrollVelocity : float = 0f;
private var timeTouchPhaseEnded : float = 0f;
private var inertiaDuration : float = 1.1f;

//private var Andriod_APP_ID = “507f8c91e33bb50c00000020”;

var Revmov : RevMobAndroid;

//function Awake()
//{
// Revmov = new RevMobAndroid(Andriod_APP_ID);
//}
function Start()
{
sw = Screen.width;
sh = Screen.height;
isMain_menu = true;
isAbout_screen = false;
isCredit_Screen = false;
isSetting_screen = false;
isCredit_Screen = false;
if(!GameObject.Find(“Sound_Manager”) && !GameObject.Find(“Sound_Manager(Clone)”) )
{
Instantiate(bg_sound);
}
volumebar = 10;

AdvertisementHandler.Instantiate("a1509a408f3b262", 
	                                 AdvertisementHandler.AdvSize.BANNER, 
	                                 AdvertisementHandler.AdvOrientation.HORIZONTAL, 
	                                 AdvertisementHandler.Position.TOP, 
	                                 AdvertisementHandler.Position.CENTER_HORIZONTAL, false, 
	                                 AdvertisementHandler.AnimationInType.SLIDE_IN_LEFT, 
	                                 AdvertisementHandler.AnimationOutType.FADE_OUT, 
	                                 AdvertisementHandler.LevelOfDebug.LOW);
    AdvertisementHandler.EnableAds();
    
   // RevMobAndroid.RevMobAndroid(Andriod_APP_ID);

}

function OnGUI ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
isMain_menu = true;
isAbout_screen = false;
isCredit_Screen = false;
isSetting_screen = false;
isCredit_Screen = false;
}
if(Input.GetKeyDown(KeyCode.Home))
{
Application.Quit();
}
if(isMain_menu)
{
GUI.DrawTexture(Rect(0,0,sw,sh),bg_texure);
if(GUI.Button(Rect(sw/7.5,sh/3.1,sw/5.2,sh/11),“”,GUIStyle.none))
{
Application.LoadLevel(“1_Level_Selection”);
}
if(GUI.Button(Rect(sw/7.5,sh/2.3,sw/5.2,sh/11),“”,GUIStyle.none))
{
isMain_menu = false;
isAbout_screen = true;
}
if(GUI.Button(Rect(sw/7.9,sh/1.8,sw/4.5,sh/11),“”,GUIStyle.none))
{
isMain_menu = false;
isSetting_screen = true;
}
if(GUI.Button(Rect(sw/7.9,sh/1.5,sw/4.5,sh/11),“”,GUIStyle.none))
{
isMain_menu = false;
isCredit_Screen = true;
}
if(GUI.Button(Rect(sw/3.5,sh/1.25,sw/3.5,sh/8),“”,GUIStyle.none))
{
// Revmov.ShowFullscreen();
Application.OpenURL (“https://play.google.com/store/apps/developer?id=seasia+consulting”);
}

}
else if(isAbout_screen)
{
	GUI.DrawTexture(Rect(0,0,sw,sh),about_screen);

	scrollPosition = GUI.BeginScrollView (Rect (sw/2.3,sh/3.5,sw/1.5,sh/2.4),scrollPosition, Rect (sw/40, sh/800, sw/2.1, sh /1.2));
	if(sw<=480)
	{
		GUI.Box(Rect(sw/30,0,sw/1.2,sh/1.2),about_text,GUIStyle.none);
	}
	else
	{
		GUI.Box(Rect(sw/15,sh/20,sw/2.65,sh/1.2),about_text1,GUIStyle.none);
	}
	GUI.EndScrollView ();
	
	if(GUI.Button(Rect(sw/5,sh/1.34,sw/3,sh/6),"",GUIStyle.none))
	{
		isAbout_screen = false;
		isMain_menu = true;
	}
}
else if(isSetting_screen)
{
	GUI.skin = mySkin;
	GUI.DrawTexture(Rect(0,0,sw,sh),settings_bg);
	
	volumebar = GUI.HorizontalSlider (new Rect (sw/7,sh/1.75,sw/4,sh/4), volumebar, 1.0f, 10.0f);
	
	if(volumebar<=1)
	{
		GUI.DrawTexture(Rect(sw/10,sh/1.75,sw/26,sh/24),disable_tex);
		AudioListener.volume = 0;
	}
	else
	{
		GUI.DrawTexture(Rect(sw/10,sh/1.75,sw/30,sh/24),enable_tex);
		AudioListener.volume = volumebar/10;
	}
	
	GUI.DrawTexture(Rect(sw/20,sh/1.2,sw/5,sh/6),back_button);
	if(GUI.Button(Rect(sw/20,sh/1.2,sw/5,sh/6),"",GUIStyle.none))
	{
		isSetting_screen = false;
		isMain_menu = true;
	}
}
else if(isCredit_Screen)
{
	GUI.DrawTexture(Rect(0,0,sw,sh),credit_screen);
	if(GUI.Button(Rect(sw/14,sh/1.25,sw/3,sh/6),"",GUIStyle.none))
	{
		isCredit_Screen = false;
		isMain_menu = true;
	}
}

}

function Update()
{
if(isAbout_screen)
{
if (Input.touchCount != 1)
{
selected = -1;
if (scrollVelocity != 0.0f)
{
// slow down over time
var t : float = (Time.time - timeTouchPhaseEnded) / inertiaDuration;
var frameVelocity : float= Mathf.Lerp(scrollVelocity, 0, t);

			scrollPosition.y += frameVelocity * Time.deltaTime ;
			
			// after N seconds, we've stopped
			if (t >= inertiaDuration) 
				scrollVelocity = 0.0f;
		}
		return;
	}
	
	var touch : Touch= Input.touches[0];
	if (touch.phase == TouchPhase.Began)
	{
		scrollVelocity = 0.0f;
	}
	else if (touch.phase == TouchPhase.Canceled)
	{
		selected = -1;
	}
	else if (touch.phase == TouchPhase.Moved)
	{
		// dragging
		selected = -1;
		scrollPosition.y += touch.deltaPosition.y; //
	}
	else if (touch.phase == TouchPhase.Ended)
	{
        // Was it a tap, or a drag-release?
        if ( selected > -1 )
        {

// Debug.Log("Player selected row " + selected);
}
else
{
// impart momentum, using last delta as the starting velocity
// ignore delta < 10; precision issues can cause ultra-high velocity
if (Mathf.Abs(touch.deltaPosition.y) >= 10) //10
scrollVelocity = (touch.deltaPosition.y / touch.deltaTime);
timeTouchPhaseEnded = Time.time;
}
}
}

}

/*…
Scripts Name : scores_update_coins

…*/

var sw : float;
var sh : float;

private var objcharacter_control : CharacterController1;

private var obj_soundmanage : Sound_Manager;

function Start()
{
objcharacter_control = GameObject.Find(“Duck”).GetComponent(“CharacterController1”);
obj_soundmanage = GameObject.Find(“SoundManager”).GetComponent(“Sound_Manager”);
}

function OnTriggerEnter(Coll:Collider)
{
if(Coll.gameObject.layer == 10)
{
obj_soundmanage.Play_RespectiveSound(3);
objcharacter_control.Score += 1;
gameObject.active = false;
objcharacter_control.coins_collectd += 1;
}
}

/*…
Scripts Name : Obstacles_destroy

…*/

var obstacle_pit : GameObject;

var target_duck:Transform;

var objects_num = 2;

var rand_position : int = 15;
var level_selected : int;
var random_range_limit : int = 0;

var haystacks_prfab:GameObject;
var diamond:GameObject;
var Pearl:GameObject;
var coin_prfab:GameObject;
var wohoo_prfab:GameObject;
var dang_plant:GameObject;
var cactus_gaint1 : GameObject;
var cactus_gaint2 : GameObject;
var hay_gravity : GameObject;

function Start()
{
level_selected = PlayerPrefs.GetInt(“Level_selected”);
if(level_selected ==1)
{
random_range_limit =2;
}

if(level_selected ==2)
{
	random_range_limit =4;
}

if(level_selected ==3)
{
	random_range_limit =5;
}

if(level_selected ==4)
{
	random_range_limit = 8;
}

if(level_selected ==5)
{
	random_range_limit = 10;
}

}

function obstacle_instantiate()
{
//yield WaitForSeconds(1);
for(var i=0;i rand_position)
{
// print(“Duck” + target_duck.position.x + “random” + rand_position);
obstacle_instantiate();
}
}

/*…
Scripts Name : Obstacles_initiation

…*/

private var target_duck:GameObject;

function Start()
{
target_duck = GameObject.Find(“Duck”);
}
function Update ()
{
if(transform.position.x + 10 < target_duck.transform.position.x)
{
Destroy (gameObject);
// Debug.Log(“destroy”);
}
}

/*…
Scripts Name : Objects_Destroy

…*/

private var duck:GameObject;

var retry_btn_texture : Texture2D;
var levelsln_btn_texture : Texture2D;
var target_texture : Texture2D;
var duck_tx : Texture2D;

var duck_destroyed : boolean;

private var ref_packedsprite1 : PackedSprite;

function Start()
{
duck = GameObject.Find(“Duck”);
duck_destroyed = false;
ref_packedsprite1 = GameObject.Find(“Duck”).GetComponent(“PackedSprite”);
}
function OnCollisionEnter(coll:Collision)
{
if(coll.gameObject.layer == 11 )
{
ref_packedsprite1.PlayAnim(2);
duck_destroyed = true;
gameObject.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
transform.collider.isTrigger = true;
}

if(coll.gameObject.layer == 19)
{
	duck_destroyed = true;
	gameObject.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
	transform.collider.isTrigger = true;
}

if(coll.gameObject.layer == 16 )
{
	ref_packedsprite1.PlayAnim(3);
	duck_destroyed = true;
	gameObject.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
	transform.collider.isTrigger = true;
}

}

function OnTriggerEnter(colli : Collider)
{
if(colli.gameObject.layer ==17)
{
ref_packedsprite1.PlayAnim(3);
duck_destroyed = true;
gameObject.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
transform.collider.isTrigger = true;
}
}
/*…
Scripts Name : CameraFollow

…*/

var target : Transform;

var smooth = 0.3;
var distance = 40.0;
private var xVelocity = 0.0;

function Update ()
{
// Damp angle from current y-angle towards target y-angle
var xAngle : float = Mathf.SmoothDampAngle(transform.eulerAngles.x,target.eulerAngles.x, xVelocity, smooth);
// Position at the target
var position : Vector3 = target.position;
// Then offset by distance behind the new angle
position += Quaternion.Euler(xAngle,0, 0) * Vector3 (0,0, -distance);
// Apply the position
transform.position.x = position.x + 0.7;
}
/*…
Scripts Name : boomerrang_motion

…*/

var isrotate:boolean;
var boom_touched: boolean;

private var obj_soundmanage : Sound_Manager;

function Start()
{
isrotate=false;
boom_touched = false;
obj_soundmanage = GameObject.Find(“SoundManager”).GetComponent(Sound_Manager);
}

function Update ()
{
if(isrotate && gameObject)
rotate();
}

function OnCollisionEnter(col:Collision)
{
if(col.gameObject.layer == 10)
{
obj_soundmanage.Play_RespectiveSound(4);
isrotate=true;
gameObject.rigidbody.velocity.x = 8;
boom_touched = true;
}

if(col.gameObject.layer == 17)
{
	col.collider.isTrigger = true;
}

}

function rotate()
{
transform.Rotate(0, 360Time.deltaTime, 0);
}
/

Scripts Name : Boom_cactus

…*/

var boomer_rang : GameObject;

var packed_sprite_ref : PackedSprite;
private var initial_position : float;

static var counter : int;
var check_for_position : boolean;

function Start()
{
check_for_position = true;
initial_position = boomer_rang.transform.position.x;
counter = 0;
}

function OnTriggerEnter(colli:Collider)
{
if(colli.collider.gameObject.tag == “boomerrang”)
{
packed_sprite_ref.DoAnim(0);
counter=counter+1;
}
}

function Update()
{
if(check_for_position)
{
if(counter>=5 && initial_position != boomer_rang.transform.position.x)
{
Destroy(boomer_rang);
check_for_position = false;
counter = 0;
}
}
}
/*…
Scripts Name : Cloud_reposition

…*/

var character : Transform;

function Start()
{
character = GameObject.Find(“Duck”).transform;
}

function Update ()
{
gameObject.rigidbody.velocity.x = -5;
if((character.position.x - gameObject.transform.position.x) >35)
{
gameObject.transform.position.x += 80;
}
}
/*…
Scripts Name : DonotDestroy

…*/

function Start ()
{
DontDestroyOnLoad(gameObject);
}

/*…
Scripts Name : Layer0

…*/

private var character : Transform;

function Start()
{
character = GameObject.Find(“Duck”).transform;
}

function Update ()
{
if((character.position.x - transform.position.x) >3)
{
transform.position.x += 7;
}
}

  1. You’re in play mode. You can’t save when you’re in play mode.

  2. You’re in play mode to start out with, and since objects created in play mode are temporary, when you stop play mode, they go away.

In short, you have “not in play mode” and “play mode” reversed.

/*
Script Name : CharacterController

…*/

var sw : float;
var sh : float;
var play_animation_default : float;
var gravity : float;

var play_normal:boolean;
var isgrounded : boolean;
var go : boolean;
var touch_up : boolean;
var touch_down : boolean;
var isUpPressed : boolean;
var isGrounded : boolean;
var isplaying : boolean;

var advertisement_handler:AdvertisementHandler;
private var obj_obstacleinitiation : Obstacles_initiation;

var packed_sprite_ref : PackedSprite;

var ref1 : Touch;
var hit: RaycastHit;
var start_time:Time;

var up_button : GUITexture;
var down_button : GUITexture;
var coustam_gui : GUIStyle;

var btn_texture : Texture2D;
var target_texture : Texture2D;
var resume_btn : Texture2D;
var Exit_btn : Texture2D;

var touchCounter : int;
var run:int;
var speed : float;
var coins_collectd : int;
var daimond_collected : int;
var pearl_collected :int;
var Score:int;
var level_selected : int;

var up :GUITexture;
var down :GUITexture;

var upprefab:GUITexture;
var downprefab:GUITexture;

private var obj_Objects_Destroy : Objects_Destroy;
private var obj_resume_screen : resume_screen;
private var obj_soundmanager1 : Sound_Manager;

function Awake()
{
AdvertisementHandler.DisableAds();
//advertisement_handler.DisableAds();
}
function Start()
{
// AdBinding.destroyAdBanner(); //Destroy iAd
//AdvertisementHandler.DisableAds();

sw = Screen.width;
sh = Screen.height;
speed = 1.8;
isgrounded = false;
isplaying = true;
obj_obstacleinitiation = GameObject.Find("layer0").GetComponent("Obstacles_initiation");
obj_Objects_Destroy = 	GameObject.Find("Duck").GetComponent(Objects_Destroy);
obj_resume_screen = 	GameObject.Find("Main Camera").GetComponent(resume_screen);
obj_soundmanager1 = GameObject.Find("SoundManager").GetComponent("Sound_Manager");

//	yield WaitForSeconds(3);
obj_obstacleinitiation.enabled = true;
play_normal = true;
touchCounter = 0;
daimond_collected = 0;
pearl_collected = 0;
coins_collectd = 0;
level_selected = PlayerPrefs.GetInt("Level_selected");
gameObject.transform.position.x=0;

}

function Update ()
{
run = gameObject.transform.position.x*2;
// Debug.Log(run);
if(!isUpPressed)
{
gameObject.rigidbody.velocity.x = speed;
}
if(Input.touchCount>0)
{
ref1 = Input.GetTouch(0);

	if(ref1.phase == TouchPhase.Began)
	{
		if(up_button.HitTest(ref1.position) && touchCounter <2)
		{			
			touchCounter += 1;

// isUpPressed = true;
touch_up = true;
gameObject.rigidbody.velocity = Vector3(speed,4,0);
}

		if(down_button.HitTest(ref1.position))
		{
			obj_soundmanager1.Play_RespectiveSound(5);
			touch_down = true; 
			packed_sprite_ref.DoAnim(0); 
			var collider_ref : CapsuleCollider = gameObject.collider; 
			collider_ref.height = .14; 
			collider_ref.radius = .15; 
			collider_ref.direction = 0; 
		}
	}
	
	if(ref1.phase == TouchPhase.Ended)
	{			
		if(touch_down)
		{
			packed_sprite_ref.DoAnim(1); 
			var collider_ref1 : CapsuleCollider = gameObject.collider; 
			collider_ref1.height = .5; 
			collider_ref1.radius = .1; 
			collider_ref1.direction = 1;
		} 
		isUpPressed = false;
		touch_up = false;
		touch_down = false;
	}				
}

}

function OnGUI()
{
if(!obj_Objects_Destroy.duck_destroyed)
{
if(obj_resume_screen.level_finish == false)
{
if(!go)
{
GUI.DrawTexture(Rect(sw/1.16,sh/100,sw/8,sh/6),btn_texture);
if(GUI.Button(Rect(sw/1.16,sh/100,sw/8,sh/6)," ",GUIStyle.none))
{
packed_sprite_ref.PauseAnim();
Time.timeScale = 0.0;
go =true;
Destroy(GameObject.FindGameObjectWithTag(“up”));
Destroy(GameObject.FindGameObjectWithTag(“down”));

// Destroy(up);
// Destroy(down);

// up.enabled = false;
// down.enabled = false;
}
}

		if(go)
		{
			
			GUI.DrawTexture(Rect(sw/3,sh/6,sw/3,sh/1.5),target_texture);
			GUI.DrawTexture(Rect(sw/2.4,sh/3.5,sw/6,sh/5),resume_btn);
			if(GUI.Button(Rect(sw/2.4,sh/3.5,sw/6,sh/5),"",GUIStyle.none))
			{
				packed_sprite_ref.UnpauseAnim();
				Time.timeScale = 1;
				go =false;
				
				up_button = Instantiate (upprefab, Vector3( 0.95, 0.09, 0), Quaternion.identity);
				down_button=Instantiate (downprefab, Vector3( 0.05, 0.1, 0), Quaternion.identity);

// up.enabled = true;
// down.enabled = true;

			}
			
			GUI.DrawTexture(Rect(sw/2.4,sh/1.8,sw/6,sh/5),Exit_btn);
			if(GUI.Button(Rect(sw/2.4,sh/1.8,sw/6,sh/5),"",GUIStyle.none))
			{
				Application.LoadLevel("1_Level_Selection");
				Time.timeScale = 1;
			}
		}
				
	}
}

}

function OnCollisionEnter(coll:Collision)
{
if(coll.gameObject.layer == 9)
touchCounter = 0;
}

function OnTriggerEnter(coll : Collider)
{
if(coll.gameObject.layer == 15)
{
obj_soundmanager1.Play_RespectiveSound(3);
daimond_collected += 1;
Score = Score + 10;
Destroy(coll.gameObject);
}

if(coll.gameObject.layer==13)
{
	obj_soundmanager1.Play_RespectiveSound(3);
	pearl_collected += 1;
	Score=Score + 5;
	Destroy(coll.gameObject);
}

}

function OnApplicationPause(pause : boolean)
{
if(pause)
{
if(!obj_Objects_Destroy.duck_destroyed)
{
packed_sprite_ref.PauseAnim();
go = true;
Time.timeScale = 0;
}
}
else if(!go)
{
Time.timeScale = 1;
packed_sprite_ref.UnpauseAnim();
}
}