|
Hi guys, someone was so friendly to give me this code for my platform game but i would like to make it for android and what I want is that when someone touches the screen the character jumps, this game is made for pc and i realy don't know how i should change this to work on android ty in advance! ........................................................CODE............................................................. var speed: float = 2; // move speed var jumpSpeed: float = 12; // initial jump speed var gravity: float = 30; private var cc: CharacterController; private var vSpeed: float; function Update(){ var moveDir = transform.forward * speed; // calculate the horizontal speed if (!cc) cc = GetComponent(CharacterController); // get the CharacterController if (cc.isGrounded){ // when grounded... } vSpeed -= gravity*Time.deltaTime; // apply a physically correct gravity moveDir.y = vSpeed; // add the vertical speed cc.Move(moveDir*Time.deltaTime); // and finally move the character }
(comments are locked)
|
So 4 errors: line 14 (foreach...) 2 errors: error 1: expecting ) found 'touch'. error 2: Unexpected token: ). line 16 (if..) 1error: Unexpected token: if. line 18 (vSpeed..) 1error: expecting :, found '=' so it didn't realy work, but do you you think you could fix those 4 errors? maybe i showed you a bad example lol. try the things bor walch suggested those should work
Apr 02 '12 at 06:41 PM
MD_Reptile
(comments are locked)
|
|
All you need to change is the (Input.GetButtonDown("Jump")). You can use Input.GetTouch for this. But You can also use Input.GetMouseButton. Check out the unity script reference for info on these functions.
(comments are locked)
|
|
All you need to change is the (Input.GetButtonDown("Jump")). You can use Input.GetTouch for this. But You can also use Input.GetMouseButton. Check out the unity script reference for info on these functions.
(comments are locked)
|
|
you need something like this (please check as correct answer if this works for you): you would need to stick that code in the place of this one: if (Input.GetButtonDown("Jump")){ // unless the character jumps vSpeed = jumpSpeed; } PS: what this code does is takes a touch input (i think it works on iOS exactly the same way) anywhere on screen, and then makes whatever code happen inside the if statement.
Apr 02 '12 at 03:24 PM
MD_Reptile
Hi MDReprilte, foreach (Touch touch in Input.touches) --> 2 errors : 1)expecting ) found 'touch'. 2) Unexpected token: ). { if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) ---> 1error: 1) unexpected token: if. { vSpeed = jumpSpeed; ---> expecting :,found '=' } } so it didn't exactly work, do you think you can fix those 4 errors?
Apr 02 '12 at 04:52 PM
starvar
Maybe your using java script, this example is c# sorry
Dec 30 '12 at 05:00 AM
MD_Reptile
(comments are locked)
|
|
can we use a simple gui button? or a gui button for easy things like shooting? Whats wrong with my karma?
Dec 30 '12 at 02:44 AM
Lost_C4
People must be voting down your answer comment. You should only answer with solutions.
Dec 30 '12 at 04:41 AM
MD_Reptile
unrelated/Off topic. it seems like this should be an entirely different question, but more thought out, or an actual comment to the original question.
Dec 30 '12 at 05:30 AM
gardian06
(comments are locked)
|
