x


C# - How change transform.translate of an gameObject by touching touchscreen!

I want change the speed of an gameObject by touching the touchscreen. If a ball fall with this code, how can i do to change the speed of the ball for a period of time (1-2 sec)?

public float apeed = 1;

void Update(){
transform.Translate(0,-speed,0)
}
more ▼

asked Jun 30 '12 at 12:17 PM

ppddgg gravatar image

ppddgg
19 6 10 12

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

1 answer: sort voted first

You need to modify the velocity of the rigidbody. If it happens once on touch, you can do it in Update. If it's continuous, do it in FixedUpdate.

more ▼

answered Jun 30 '12 at 03:29 PM

Berenger gravatar image

Berenger
11k 12 19 53

(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:

x4142

asked: Jun 30 '12 at 12:17 PM

Seen: 361 times

Last Updated: Jun 30 '12 at 03:29 PM