Это 2d платформер он у меня умирает когда я падаю за остров, но я хочу чтоб он ещё умирал от шипов
(если что на шипах тэг kill)
помогите плиз
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq.Expressions;
using System.Security.Cryptography;
using UnityEngine;
using UnityEngine.SceneManagement;
public class cntrl : MonoBehaviour
{
public float speed;
public float jumpForce;
private float moveInput;
public Joystick joystick;
private Rigidbody2D rb;
private bool facingright = true;
private bool IsGrounded;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGrounded;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
moveInput = joystick.Horizontal;
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (facingright == false && moveInput > 0)
{
Flip();
}
else if (facingright == true && moveInput < 0)
{
Flip();
}
}
private void Update()
{
float verticalMove = joystick.Vertical;
{
IsGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGrounded);
if(IsGrounded == true && verticalMove >= .5f)
{
rb.velocity = Vector2.up * jumpForce;
}
}
}
void Flip()
{
facingright = !facingright;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Respawn")
{
SceneManager.LoadScene(0);
}
}
}