Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

C# - How change public speed by touching touchscreen!

Discussion in 'Scripting' started by ppddgg, Jul 1, 2012.

  1. ppddgg

    ppddgg

    Joined:
    Jun 24, 2012
    Posts:
    6
    Hi! I'm a little newbe. I'm trying to understand the basics of c# in unity.
    My problem is that I want to change speed value by touching the touchscreen. This is a c# code that I tried to do.
    Can someone help me please?

    Code (csharp):
    1. public  float speed = 1;
    2.    
    3.    
    4.     void Update () {
    5.         transform.Translate(0,-speed,0);
    6.            
    7.     if(Input.touchCount == 1  Input.GetTouch(1).phase == TouchPhase.Began){
    8.             speed = 2;
    9.         }