Cheat code in java not working
I tried to translate from c# to java a cheat code system and I combine the cheat code system into the cloud system, so when i input the code, the sky is changing the appearance and if I write the code again, the sky is changing back to normal. The cheat code system is in Update and Start. The problem is I have many error logs in unity. Here is the script:
var Player : Transform;
var CloudsSpeed = 1.75;
private var distance = 10.0;
private var height = 0;
private var heightDamping = 0;
private var rotationDamping = 0;
var zero : boolean = false;
var rend: Renderer;
private var string[] cheatCode;
private var index : int;
function Start ()
{
rend = GetComponent.<Renderer>();
cheatCode = new string[] { "c", "r", "a", "z", "y", "w" "o", "r", "l", "d" };
index = 0;
}
function Update()
{
transform.Rotate(0,Time.deltaTime*CloudsSpeed ,0);
if (Input.anyKeyDown)
{
if (Input.GetKeyDown(cheatCode[index]))
{
index++
}
else
{
index = 0;
}
if (index == cheatCode.Length)
{
if (zero)
zero = false;
else
zero = true;
if(zero)
{
rend.material.mainTextureScale = Vector2 (5,25);
CloudsSpeed = 3;
}
else
{
rend.material.mainTextureScale = Vector2 (1,1);
CloudsSpeed = 1.75;
}
}
}
function LateUpdate ()
{
if (!Player)
return;
var wantedHeight = Player.position.y + height;
var currentHeight = transform.position.y;
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
transform.position = Player.position;
transform.position.y = currentHeight;
}
What I can change in this script? Please help me!
Answer by DincaAlin · Oct 01, 2015 at 05:17 PM
I have tried to change that javascript into c# script and I succeded, but I have this error: Assets/SimpleCloudSystem by RM/SCS.cs(62,35): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'. Consider storing the value in a temporary variable THE ERROR IS ABOUT THIS LINE: (transform.position.y = currentHeight;)Here is the script in c#:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SCS : MonoBehaviour {
public Transform Player;
float CloudsSpeed = 1.75f;
private float distance = 10.0f;
private float height = 0;
private float heightDamping = 0;
private float rotationDamping = 0;
public bool zero = false;
Renderer rend;
void Start ()
{
rend = GetComponent<Renderer>();
}
void Update ()
{
transform.Rotate(0,Time.deltaTime*CloudsSpeed ,0);
if (Input.GetKeyDown("0"))
{
if (zero)
zero = false;
else
zero = true;
if(zero)
{
rend.material.mainTextureScale = new Vector2(5, 25);
CloudsSpeed = 25f;
}
else
{
rend.material.mainTextureScale = new Vector2(1, 1);
CloudsSpeed = 1.75f;
}
}
}
void LateUpdate ()
{
if (!Player)
return;
{
float wantedHeight = Player.position.y + height;
float currentHeight = transform.position.y;
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
transform.position = Player.position;
transform.position.y = currentHeight;
}
}
}
Your answer
Follow this Question
Related Questions
Cheat Engine Detection? 3 Answers
Unexpected Symbol 'int' 1 Answer
using cheat codes to enable a camera effect. 0 Answers
Passing Byte[] to JSLIB method 1 Answer