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:
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.
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:
using UnityEngine;
using System.Collections;
public class AudioTest : MonoBehaviour {
public AudioClip myClip;
public AudioSource audio;
void Start()
{
audio.clip = myClip;
}
void OnTriggerEnter(Collider obj)
{
if (obj.tag == "Player")
{
audio.Play();
}
else
{
audio.Stop();
}
}
}