So, I wrote some scripts for my 2d game, but I made them use 3d physics, so now I can’t fix them. Help would greatly be appreaciated. The two scripts are to on collision make the player respawn
using UnityEngine;
using System.Collections;
public class MYCLASSNAME : MonoBehaviour {
Transform spawn;
void OnTriggerEnter ( Collider other ){ if (cother.tag == “Player”)
{ other.transform.position = spawn.position; }
}
}
And to make audio play on collision
- 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();
- }
- }
- }
Also, if someone could format them correctly, that would make my day