Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Novice Question: How can I tell an object x+=1?

Discussion in 'Scripting' started by From-Soy-Sauce, Jan 7, 2014.

  1. From-Soy-Sauce

    From-Soy-Sauce

    Joined:
    Jan 7, 2014
    Posts:
    162
    Hello, I am new to this, my programing knowledge is some Java script, but mostly I know scripting just from Game Maker's GML.

    That said, I'd like to know a bit of how to use Unity but I cannot find any tutorials on youtube that do not require the Physics Engine. I understand that said engine is very powerful and useful. but for my purposes I do not need it.

    I would like to know how to tell a ball object to check every step of the game if the player is pressing the right arrow key, and if that is true that that x+=1; (at least that's how it would be coded in a game maker game)

    Thanks in advanced.
     
  2. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    i suggest you to go find Teaching section in this forum and follow the WalkerBoys tutorial series and in a week you are going to be ready to create a VERY GOOD GAME!
     
  3. softwizz

    softwizz

    Joined:
    Mar 12, 2011
    Posts:
    793
    Last edited: Jan 7, 2014
  4. _Nick

    _Nick

    Joined:
    Jun 29, 2013
    Posts:
    30
    Code (csharp):
    1. if(Input.GetKey(KeyCode.LeftArrow))
    2. {
    3.     GameObject_Name.transform.Translate(0.1f * Time.deltaTime, 0, 0);
    4. }
    That should be enough for a simple "move when a key is hit."
     
  5. From-Soy-Sauce

    From-Soy-Sauce

    Joined:
    Jan 7, 2014
    Posts:
    162
    Ahh thanks. Your answer reminds me of another question I had though.

    How do I set the games frame rate at the start of the game and any time during the middle of the game?
     
  6. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Why would you ever want to do that?
     
  7. From-Soy-Sauce

    From-Soy-Sauce

    Joined:
    Jan 7, 2014
    Posts:
    162
    Like I said, I came from Game Maker, and soo- setting the frame rate manually is what I'm comfortable with.
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I recommend you start here http://unity3d.com/learn

    and work through, it's done by unity themselves and is a wonderful resource.