GeoJam2021/Assets/Scripts/Death.cs

26 lines
602 B
C#
Raw Normal View History

2021-07-20 20:10:12 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Death : MonoBehaviour
{
2021-07-21 09:33:24 +02:00
public SpawnStorage spawnstor;
public AudioClip damage;
public AudioSource sfx;
2021-07-20 20:36:16 +02:00
void Start() {
2021-07-20 20:10:12 +02:00
}
2021-07-20 20:36:16 +02:00
private void OnCollisionEnter2D (Collision2D collisionInfo)
{
2021-07-20 21:40:21 +02:00
if (collisionInfo.collider.name == "Player") {
2021-07-21 09:33:24 +02:00
collisionInfo.collider.transform.position = spawnstor.spawnpoint;
2021-07-20 21:40:21 +02:00
collisionInfo.collider.GetComponent<Rigidbody2D>().velocity = Vector3.zero;
2021-07-21 09:33:24 +02:00
sfx.clip = damage;
sfx.Play();
2021-07-20 21:40:21 +02:00
}
2021-07-20 20:10:12 +02:00
}
}