Search Unity

Scripting errors

Discussion in 'Scripting' started by Swagbags, Aug 28, 2015.

  1. Swagbags

    Swagbags

    Joined:
    Aug 28, 2015
    Posts:
    3
    Ive just started learning about this so i don't know what im doing. Currently following the official tutorial 'Make A Ball Game'. Got as far as finishing the script, which is identical to the tutor's script, but i have errors and he doesnt. Different version? Missing software? What should i do?
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    You should first post the code in CODE TAGS then tge errors, so people can help.
     
  3. georetro

    georetro

    Joined:
    Jan 18, 2013
    Posts:
    218
    Yeah we'll need to see the actual errors first before we can help you!
     
  4. Swagbags

    Swagbags

    Joined:
    Aug 28, 2015
    Posts:
    3
    Lol! Yeh. Probably better!

    using UnityEngine;
    using System.Collections;

    public class PlayerController : MonoBehaviour {

    private Rigidbody rb;

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

    FixedUpdate {}

    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");

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

    rb.AddForce {movement};
    }
    }
     
  5. Swagbags

    Swagbags

    Joined:
    Aug 28, 2015
    Posts:
    3
    Is there a certain method of posting "Code Tags" on here?
     
  6. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
    Yes. Enclose you script in [ code=CSharp] [ /code (without the space) or use the 6th icon from the right in the editors icon bar.
     
    Last edited: Aug 28, 2015
  7. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
    You need to change
    Code (CSharp):
    1. FixedUpdate {}
    into
    Code (CSharp):
    1. FixedUpdate() {
    2.  
     
    georetro likes this.
  8. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Or simply do insert/code, and yopy your code to there
     
  9. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    And you forgot the errors, those are essential too.
     
  10. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    The error is at FixedUpdate, you can't just put a function like that, you need a void before it, so the game actually knows, that it's a function, and a (), because of the same reason.