
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
수업시간에 배운것을 응용하여 사용해보았는데 충돌처리를 하더라도 충돌이 발생하지않습니다.. ㅠㅠ

작성한 코드 및 에러 메세지
1번사진의 코드
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
public class building : MonoBehaviour
{
public float dead = 0.0f;
public float health = 5.0f;
Rigidbody2D rigid;
private void Awake()
{
rigid = GetComponent<Rigidbody2D>();
//중력 지맘대로 바꾸는 코드rigid.gravityScale = Random.Range(1, 5);
}
void Start()
{
float x = Random.Range(-3f, 3f);
float y = Random.Range(100f, 100f);
transform.position = new Vector3(x, y, 0);
float size = Random.Range(0.5f, 1.5f);
transform.localScale = new Vector3(size, size, 0);
}
// Update is called once per frame
void FixedUpdate()
{
}
void OnTriggerEnter2D(Collider2D coll)
{
if (!coll.CompareTag("Weapon"))
return;
health -= coll.GetComponent<Weapon>().damage;
Debug.Log("맞음");
if (health > 0)
{
health -= 1.0f;
}
else
{
Dead();
}
}
void Dead()
{
gameObject.SetActive(false);
Debug.Log("삭제");
}
}
