Unity3D Collect x amount 2 unlock level
THIS IS Java# script: And C# GOOD 4 2D GAMES AND 3D GAMES !
--------------------------------------------------------------------------------------
DIRECT DOWNLOAD HERE
THIS IS BACKUP IN TEXT FORM
--------------------------------------------------------------------------------------
FOLDER PUT ON YOUR COIN
--------------------------------------------------------------------------------------
SCRIPT 1 .
1. Create New C# and name it : CoinRotation
2. Copy & Past this text and save C# :
--------------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class CoinRotation : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
gameObject.transform.Rotate(0, 0, 5);
}
}
--------------------------------------------------------------------------------------
SCRIPT 2. DisableMeshOnCoin
1. Create New Java and name it : DisableMeshOnCoin
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
function OnTriggerEnter(Trigger : Collider)
{
if (Trigger.tag == "Player")
{
renderer.enabled = false;
}
}
--------------------------------------------------------------------------------------
SCRIPT 3. GUIAppear
1. Create New Java and name it : GUIAppear
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
private var guiShow : boolean = false;
var PutTextureHere : Texture;
function OnTriggerStay (Col : Collider)
{
if(Col.tag == "Player")
{
guiShow = true;
}
}
function OnGUI()
{
if(guiShow == true)
{
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height - Screen.height,248,46), PutTextureHere);
}
}
--------------------------------------------------------------------------------------
SCRIPT 4. PlayAudioOnCoin
1. Create New Java and name it : PlayAudioOnCoin
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
@script RequireComponent(AudioSource)
public var clip : AudioClip;
function OnTriggerEnter(hit : Collider){
audio.PlayClipAtPoint(clip, Vector3 (5, 1, 2));
}
--------------------------------------------------------------------------------------
And Here Are Some FREE graphic design materials :)
THIS IS BACKUP IN TEXT FORM
--------------------------------------------------------------------------------------
FOLDER PUT ON YOUR PLAYER
--------------------------------------------------------------------------------------
SCRIPT 1. ChAftAllCollCoins
1. Create New Java and name it : ChAftAllCollCoins
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
var level:int;
function OnTriggerEnter( other : Collider ) { if (other.tag == "Coin") yield WaitForSeconds (0.9); { Destroy(other.gameObject); } }
function Update () { print(GameObject.FindGameObjectsWithTag("Coin").Length);
if(GameObject.FindGameObjectsWithTag("Coin").Length==0) {Application.LoadLevel(level);}
}
--------------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class gameobjects : MonoBehaviour {
// Use this for initialization
int CoinLeft = 0;
bool killedAllCoin = false;
void Start () {
CoinLeft = 10; // or whatever;
}
// Update is called once per frame
void Update () {
GameObject[] Coin = GameObject.FindGameObjectsWithTag("Coin");
CoinLeft = Coin.Length;
if(Input.GetKeyDown(KeyCode.F1))
{
CoinLeft --;
}
if(CoinLeft == 0)
{
endGame();
}
}
void endGame()
{
killedAllCoin = true;
}
void OnGUI()
{
if(killedAllCoin)
{
GUI.Label(new Rect (0,0,200,20),"all gone");
}
else
{
GUI.Label(new Rect (0,0,200,20),"Coin Remaining : " + CoinLeft);
}
}
}
THIS IS BACKUP IN TEXT FORM
--------------------------------------------------------------------------------------
FOLDER PUT ON YOUR COIN
--------------------------------------------------------------------------------------
SCRIPT 1 .
1. Create New C# and name it : CoinRotation
2. Copy & Past this text and save C# :
--------------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
public class CoinRotation : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
gameObject.transform.Rotate(0, 0, 5);
}
}
SCRIPT 2. DisableMeshOnCoin
1. Create New Java and name it : DisableMeshOnCoin
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
function OnTriggerEnter(Trigger : Collider)
{
if (Trigger.tag == "Player")
{
renderer.enabled = false;
}
}
SCRIPT 3. GUIAppear
1. Create New Java and name it : GUIAppear
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
private var guiShow : boolean = false;
var PutTextureHere : Texture;
function OnTriggerStay (Col : Collider)
{
if(Col.tag == "Player")
{
guiShow = true;
}
}
function OnGUI()
{
if(guiShow == true)
{
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height - Screen.height,248,46), PutTextureHere);
}
}
SCRIPT 4. PlayAudioOnCoin
1. Create New Java and name it : PlayAudioOnCoin
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
@script RequireComponent(AudioSource)
public var clip : AudioClip;
function OnTriggerEnter(hit : Collider){
audio.PlayClipAtPoint(clip, Vector3 (5, 1, 2));
}
And Here Are Some FREE graphic design materials :)
--------------------------------------------------------------------------------------
FOLDER PUT ON YOUR PLAYER
--------------------------------------------------------------------------------------
SCRIPT 1. ChAftAllCollCoins
1. Create New Java and name it : ChAftAllCollCoins
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
#pragma strict
var level:int;
function OnTriggerEnter( other : Collider ) { if (other.tag == "Coin") yield WaitForSeconds (0.9); { Destroy(other.gameObject); } }
function Update () { print(GameObject.FindGameObjectsWithTag("Coin").Length);
if(GameObject.FindGameObjectsWithTag("Coin").Length==0) {Application.LoadLevel(level);}
}
--------------------------------------------------------------------------------------
SCRIPT 2. gameobjects
1. Create New C# and name it : gameobjects
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
1. Create New C# and name it : gameobjects
2. Copy & Past this text and save :
--------------------------------------------------------------------------------------
using System.Collections;
public class gameobjects : MonoBehaviour {
// Use this for initialization
int CoinLeft = 0;
bool killedAllCoin = false;
void Start () {
CoinLeft = 10; // or whatever;
}
// Update is called once per frame
void Update () {
GameObject[] Coin = GameObject.FindGameObjectsWithTag("Coin");
CoinLeft = Coin.Length;
if(Input.GetKeyDown(KeyCode.F1))
{
CoinLeft --;
}
if(CoinLeft == 0)
{
endGame();
}
}
void endGame()
{
killedAllCoin = true;
}
void OnGUI()
{
if(killedAllCoin)
{
GUI.Label(new Rect (0,0,200,20),"all gone");
}
else
{
GUI.Label(new Rect (0,0,200,20),"Coin Remaining : " + CoinLeft);
}
}
}
--------------------------------------------------------------------------------------