Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Keyword "Void can not be used in this contex"

Discussion in 'Scripting' started by VoxelGameDesigner, Aug 11, 2018.

  1. VoxelGameDesigner

    VoxelGameDesigner

    Joined:
    Oct 25, 2014
    Posts:
    23
    Hey guys, i need help with this code, im new to unity and programming and cant seem to fix the problem. Here is the code:

    void Update () {
    float xSpeed = Input.GetAxis("Horizontal");
    float ySpeed = Input.GetAxis("Vertical");

    Rigidbody body = GetComponent<Rigidbody>();
    body.AddTorque (new Vector3(xSpeed, 0, ySpeed) * ballspeed * Time.deltaTime);

    void OnTriggerEnter(Collider other)
    {
    if (other.gameObject.CompareTag("Cubits"))
    {
    other.gameObject.SetActive(false);
    }
    }
    }


    Void OnTrigger is the one not working. Help would be much appreciated thanks :D
     
  2. VoxelGameDesigner

    VoxelGameDesigner

    Joined:
    Oct 25, 2014
    Posts:
    23
    Never mind Guys! I missed a curly bracket on the previous line of this script!