Re: Unlock Cheats

Useful script from community for unity 3d.
Post Reply
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

a very simple code for any type of game you want to give some advantage to players when they write a certain word, GTA style.

Enjoy!

Code: Select all

using UnityEngine;

public class Cheats : MonoBehaviour
{
/// <summary>
/// 
/// </summary>
public string[] m_Code;
//Privates
private int index;

/// <summary>
/// 
/// </summary>
void Start()
{
//change this word for your code word
m_Code = new string[] { "y", "o", "u", "r", "c", "o", "d", "e"};//the example code is "yourcode".
//start index from
index = 0;
}

/// <summary>
/// 
/// </summary>
void Update()
{
//if no keypress is detected
if (!Input.anyKeyDown)
return;
//if the key is pressed with the same name of current char of cheat code...
if (Input.GetKeyDown(m_Code[index]))
{
index++;//continue with the next char
}
else
{
index = 0;//return to firts char
}

if (index == m_Code.Length)//is complete word
{
Debug.Log("Cheat unlocked!");
//Your Function here
//Example MorePower();
index = 0;//return to first char again (optional).
}
}

}
How to find your Invoice Number: Here
How to find your Order Number: Here
Post Reply