2025-01-06 16:11:40 +01:00

26 lines
597 B
C#

using UnityEngine;
public class Obstacle : MonoBehaviour
{
public PlayerScript playerScript;
public GameObject playerObject;
public AudioSource audioSource;
public void Start()
{
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>();
}
public void Update()
{
}
public void OnTriggerEnter2D(Collider2D collision)
{
playerObject.transform.rotation = playerScript.initialRotation;
playerObject.transform.position = playerScript.initialPosition;
playerScript.audioSource.Play();
}
}