Hello im trying to make the roll a ball game but it does not collect the collectible instead goes through it this is the code im using and also i have checked the “istrigger” still its not being collected.
public class PlayerController : MonoBehaviour
{
private Rigidbody rb3d;
public int speed;
private void FixedUpdate()
{
float moveh = Input.GetAxis("Horizontal");
float moveV = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveh, 0.0f, moveV);
rb3d.AddForce(movement * speed);
}
private void Start()
{
rb3d = GetComponent<Rigidbody>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Coin"))
{
other.gameObject.SetActive(false);
}
}
}