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. Dismiss Notice

Getting Parsing error CS8025

Discussion in '2D' started by Messele Asfaw, Jun 27, 2015.

  1. Messele Asfaw

    Messele Asfaw

    Joined:
    Jun 23, 2015
    Posts:
    6
    I'm getting an error for this teleporting script, and I'm not sure whats wrong. Thanks in advance.

    var spawn : Transform;

    function OnTriggerEnter(other : Collider) { if (cother.tag == "Player") { other.transform.position = spawn.position; } }

    Oh and I also have a problem with playing sound on collision. I keep getting the "a namespace can only contain types and namespace declarations" error on EVERY script I've tried.
    This is the one that I'vetried fixing the most:

    public AudiClip myClip;

    void Start() { audio.clip = myClip; }

    void OnTriggerEnter(Collider obj){ if(obj.tag == "Player"){ audio.Play(); } else { audio.Stop(); } }

    It just won't clear and compile. I'm having real trouble with triggers today. Thanks in advance.
     
    Last edited: Jun 28, 2015
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    Isn't the problem that it says cother.tag, instead of other.tag?

    In the other example, it's AudioClip, not AudiClip.
     
    Messele Asfaw likes this.
  3. Messele Asfaw

    Messele Asfaw

    Joined:
    Jun 23, 2015
    Posts:
    6
    thanks im a real idiot.
     
  4. Messele Asfaw

    Messele Asfaw

    Joined:
    Jun 23, 2015
    Posts:
    6
    But this didn't solve the problem. I think it might be spacing or something else. I am a newb at coding in C Sharp so I would really appreciate it if someone formatted them correctly. And for the audio, I'm getting the A namespace can only contain types and namespace declarations.
     
  5. pappu33

    pappu33

    Joined:
    Apr 8, 2015
    Posts:
    14
    u say ur new to c# but u have actually given JS script. 0.0
     
  6. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    897
    One of your scripts seems to be UnityScript and the other seems to be C#. Also, the scripts are using 3D physics, but you are posting in the 2D section. Anyhow, the C# script should look something like this:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AudioTest : MonoBehaviour {
    5.     public AudioClip myClip;
    6.     public AudioSource audio;
    7.  
    8.     void Start()
    9.     {
    10.         audio.clip = myClip;
    11.     }
    12.  
    13.     void OnTriggerEnter(Collider obj)
    14.     {
    15.         if (obj.tag == "Player")
    16.         {
    17.             audio.Play();
    18.         }
    19.         else
    20.         {
    21.             audio.Stop();
    22.         }
    23.     }
    24. }