Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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


    Jun 24, 2012
    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;
    4.     void Update () {
    5.         transform.Translate(0,-speed,0);
    7.     if(Input.touchCount == 1  Input.GetTouch(1).phase == TouchPhase.Began){
    8.             speed = 2;
    9.         }