Search Unity

How do you set a speed of of an object

Discussion in 'Getting Started' started by thomas_kenny03, Apr 20, 2017.

  1. thomas_kenny03

    thomas_kenny03

    Joined:
    Apr 20, 2017
    Posts:
    1
    Help I am stuck on this piece of code to set the speed of my object
    I don't know how to finish this piece
    private float speed 5f
    If you can help thanks!

    tk
     
  2. MasterSubby

    MasterSubby

    Joined:
    Sep 5, 2012
    Posts:
    252
    You should look more into general syntax for C#, or follow the Learn Tutorials here on Unity. You are simply missing an equals sign and semi colon, like such:

    Code (CSharp):
    1. private float speed = 5f;
     
    Last edited: Apr 20, 2017
    Schneider21, JoeStrout and Ryiah like this.
  3. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    By the looks of it, you may also want to learn about RigidBodies(2D) if you want to set your object into motion