Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
-1
Question by BigBlob · Apr 09, 2012 at 04:51 PM · gravitydisableenablecheat

Game Glitches and Cheat Codes

Many games like Call of Duty series have glitches and hacks, but GTA has cheat codes. In my game I need a script that has a string value of GRAVITY_5. And when I type that in game a GUI Box will show up saying "Gravity Set To 5", after the box disappears. After that is typed the players character motor jumping gravity is set to 5. And when if I type that again I'll get another one saying "Gravity Disabled", and then disappears. And so as the jumping gravity is set back to original which is 20. Please I need a script

  • Felipe

    [1]: http://answers.unity3d.com/users/11109/aldonaletto.html

    [2]: http://answers.unity3d.com/users/17559/fafase.html

Comment
Add comment · Show 4
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 by0log1c · Apr 09, 2012 at 04:58 PM 1
Share

Do not target UnityAnswers users. It seems very rude to me. That being said, take a look at UnityScript eval() function. I made myself a hack console using that.

avatar image Kleptomaniac · Apr 09, 2012 at 05:03 PM 0
Share

Yes, despite their high karma scores, there are other people on UA you know ...

avatar image FLASHDENMARK · Apr 09, 2012 at 05:34 PM 0
Share

You need a script? Of course you do, but don't ask for them, that is not very good etiquette.

And also, Aldonaletto and fafase are helpful people and talented at that, but there are plenty of others on this site that could help you, not just them.

avatar image fafase · Apr 09, 2012 at 07:04 PM 0
Share

What the hell am I doing in this question??!! Next to a guy with 50 times my knowledge!!! That's nice and that's wrong.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by FLASHDENMARK · Apr 09, 2012 at 05:46 PM

Creating a cheat console(in its basic form) is very easy. Since you ask for a script I won't give you one, you will have to figure out the details yourself.

First of you will have to utilize Unity's GUI system.

Create two textfields one where you input the name of the variable you want to change(e.g. gravity). Then in the other textfield you input what the variable should be set to.

You should now figure out what the player inputted and what he wanted the inputted variable to be. E.g if the keyword "gravity" is inputted and the other keyword "5" is inputted, you should change the gravity to 5.

You can use parseFloat(stringName) to convert the variable amount from a string to a number.

Comment
Add comment · Show 2 · 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
avatar image Kleptomaniac · Apr 09, 2012 at 05:53 PM 0
Share

Alternatively, he could not use two textfields, and ins$$anonymous$$d do a string.Split in terms of spaces (meaing that it would be inputted like this in a single textfield: gravity 5) and then use parseFloat on element 2 of the returned array.

avatar image FLASHDENMARK · Apr 09, 2012 at 07:49 PM 2
Share

Indeed he could.

avatar image
0

Answer by by0log1c · Apr 09, 2012 at 06:31 PM

UnityScript's eval will evaluate a string like it was compiled code. You should know that it uses reflection(?) behind the scene and is quite expensive, not for everyday use. What's awesome about it is you don't need to prepare statements so I use it to debug variable state at runtime and such.

Simplified, untested version of what I use:

 public var debugKey:KeyCode = KeyCode.F11;
 public var show:boolean = false;
 public var command:String = "";
 
 function Update()
 {
     if(Input.GetKeyDown(debugKey))
         show = !show;
 }
 
 function OnGUI()
 {
     if(!show)
         return;
     
     command = GUILayout.TextField(command);
     if(GUILayout.Button("Execute"))
     {
         eval(command);
         command = "";
     }
 }
Comment
Add comment · Show 2 · 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
avatar image BigBlob · Apr 14, 2012 at 10:30 PM 0
Share

Thanks it works great - Just a question : The command executed is a script attached to the player right?

avatar image ckosmic · Jun 22, 2013 at 02:29 PM 0
Share

When I type nothing in the box, the command still works. Any help?

avatar image
0

Answer by $$anonymous$$ · May 01, 2012 at 04:57 PM

Here : unitynoobs you can download a small project with this answer!

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.

Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

how to disable patent components incode 0 Answers

Disable/Enable Buttons and Text plz help jc 1 Answer

Can't enable/disable canvas on Android device 0 Answers

Spotlight help 1 Answer

Disable/Enable Status Bar 2 Answers


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