Search Unity

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:
    9,859
    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:
    3,512
    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:
    16,860
    Vertical has a capital V.
     
    Ryiah likes this.
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    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.