• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by DincaAlin · Sep 30, 2015 at 09:40 PM · c# to javascriptcheat

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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Oct 01, 2015 at 08:15 AM 0
Share

what errors?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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;
         }
     }
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to save daily reward timer by playerprefs ? 0 Answers

How to Add time to my timer on colliding 1 Answer

[SerializeField][Range(0.1F, 100.0F)] public float speed; 2 Answers

Unsure of how to convert c# public class to javascript 1 Answer

how do you change a .unity file to a .html or web gl? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges