Search Unity

Project Roll a ball question

Discussion in 'Scripting' started by Mitrax, Apr 21, 2015.

  1. Mitrax

    Mitrax

    Joined:
    Mar 6, 2015
    Posts:
    1
    Why in the tutorial section Creating Collectable Objects PlayerController a different script, in relation to section Collecting and counting? When i try on my phone commands do not work?

    Creating Collectable Objects script

    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;

    public class PlayerConroller : MonoBehaviour
    {
    public float speed;

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

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

    GetComponent<Rigidbody>().AddForce (movement * speed * Time.deltaTime);
    }
    void OnTriggerEnter(Collider other)
    {
    if (other.gameObject.CompareTag ("Pick Up"))
    {
    other.gameObject.SetActive (false);
    }
    }
    }

    Collecting and counting script

    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;

    public class PlayerConroller : MonoBehaviour
    {
    public float speed;

    private Rigidbody rb;

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


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

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

    rb.AddForce (movement * speed);
    }

    void OnTriggerEnter(Collider other)
    {
    if (other.gameObject.CompareTag ("Pick Up"))
    {
    other.gameObject.SetActive (false);
    }
    }
    }
     
  2. psyydack

    psyydack

    Joined:
    Aug 30, 2013
    Posts:
    93
    What the error print?
    Seems your class name is different "PlayerConroller"...