x


How can I define Android or iOS inputs?

instead of Input.GetAxis("Vertical")*moveVec; what should I use for android? and also for Input.GetAxis("Horizontal") please let me know.

I want to use a simple touch on screen for moving forward. and also want to use mobile's motion to turn left and right.

If any better option then this, then also please let me know.

Thanks in advance.

more ▼

asked Apr 04 '12 at 05:54 PM

hirenkacha gravatar image

hirenkacha
701 12 18 21

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

I have got the solution for my game, i am using this code to move forward when touched the screen and stop when released the screen.

if(Input.GetTouch(0).phase==TouchPhase.Stationary)

{

 transform = moveVector * Input.touchCount;

}

else

{

 transform = moveVector * 0;

}

Thanx for replying and giving me an idea.

more ▼

answered Apr 05 '12 at 07:46 AM

hirenkacha gravatar image

hirenkacha
701 12 18 21

(comments are locked)
10|3000 characters needed characters left

You have to either calculate touch offsets using a delta position or use an onscreen joystick. You also have to catch the device's acelorometer or gyro to detect turning motion. Here is a pretty good example for detecting touch.

more ▼

answered Apr 04 '12 at 06:11 PM

SirGive gravatar image

SirGive
1.2k 25 32 50

thanx.. it really helpd me.. now m looking forward for turning motion.

Apr 05 '12 at 05:26 AM hirenkacha

accelerometer also done...

Apr 07 '12 at 03:28 PM hirenkacha

if any one need accelerometer comment here... i will post it..

Apr 16 '12 at 11:51 AM hirenkacha

I do, are you still offering your help @hirenkacha ?

Jun 04 '12 at 03:48 PM kevinseligmann

yeah sure why not..??

Jun 05 '12 at 04:09 AM hirenkacha
(comments are locked)
10|3000 characters needed characters left

If you want your car to move according to device tilt, use this

FrontLeftWheel.steerAngle = 20 * Input.acceleration.y; /* you can use any number instead of 20 for sensitivity. FrontLeftwheel is the wheel collider attached to front wheels. .y is for landscape orientation.
FrontRightWheel.steerAngle = 20 * Input.acceleration.y;
more ▼

answered Jun 05 '12 at 04:16 AM

hirenkacha gravatar image

hirenkacha
701 12 18 21

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2451
x951

asked: Apr 04 '12 at 05:54 PM

Seen: 992 times

Last Updated: Jun 05 '12 at 04:16 AM