Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

first game

Discussion in 'Getting Started' started by Nero1inen, Aug 12, 2017.

  1. Nero1inen

    Nero1inen

    Joined:
    Aug 12, 2017
    Posts:
    1
    Hey

    I wanted to code this
    game first and I do not know what went wrong. here is my code


    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour {

    private Rigidbody rb;

    void Start ()
    {
    rb = GetComponent<Rigidbody>();
    }



    void FixeUpdate ()
    {
    float moveHorizontal = Input.GetAxis("Horizontal");
    float movevertical = Input.GetAxis("vertical");

    Vector3 movement = new Vector3(moveHorizontal, 0.0f, movevertical);

    rb.AddForce (movement);
    }
    }
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    5,401
    Neither do we, because you haven't told us. Sometimes, just for fun, I like to guess, but my guesses usually turn out to be wrong. Why don't you save us the trouble and tell us what is happening that you don't want to happen, or what isn't happening that should?
     
    Georgielaa and Ryiah like this.
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,424
    Welcome to the forums, @Nero1inen! @JoeStrout is correct -- as always -- in his assessment, but I'd like to mention that your question is common enough to warrant adding to my own ongoing FAQ, which may have other relevant content for you. In response to your question here, though:
     
    JoeStrout and Ryiah like this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    14,201
    Vertical has a capital V.
     
    Ryiah likes this.
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    9,845
    Two immediate problems stand out to me.

    Code (csharp):
    1. float movevertical = Input.GetAxis("vertical");
    First, like @Kiwasi mentioned the GetAxis function is case sensitive. You need to capitalize the "V".

    Code (csharp):
    1. void FixeUpdate ()
    That said it was never getting the opportunity to run the code because of the second problem. You misspelled the function name. It needs to be "FixedUpdate".
     
    Last edited: Aug 13, 2017
    JoeStrout and Kiwasi like this.