Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Java Persistence with Spring Data and Hibernate
this week in the
Spring
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Android
Help with code
Nikola Pejovski
Greenhorn
Posts: 5
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In Unity, I have tried many buttons but I can't connect them with the (
Java
)Script.
So I made 2 gui buttons: one for jump which was easy because I had an if statement and if it's true then jump.
But I have problems with the crouch button. Bellow is my script but I can't figure out how to put the crouch code in > function OnGUI()
This is my script:
#pragma strict private var tr: Transform; private var dist: float; // distance to ground function Start(){ tr = transform; var ch:CharacterController = GetComponent(CharacterController); dist = ch.height/2; // calculate distance to ground } function Update() { var vScale = 1.0; if (Input.GetKey("s")){ vScale = 0.5; } var ultScale = tr.localScale.y; tr.localScale.y = Mathf.Lerp(tr.localScale.y, vScale, 5*Time.deltaTime); tr.position.y += dist * (tr.localScale.y-ultScale); } function OnGUI () { if(GUI.Button(new Rect(15, 330, 200, 100), "Shrink")) { } }
Curse your sudden but inevitable betrayal! And this tiny ad too!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Send parameters that are being set in a javascript from one jsp to another jsp
use object or function?
Problem getting JavaScript code supplied by course to run
Getting Distance between two addresses
clear the field and disable the back button.
More...