For some reason my tagged enemy with a box collider trigger is not triggering the OnTriggerEnter2D in my bullet script. As a test I set the ladder to an enemy, since it is a trigger as well, and it worked fine.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletBehavior : MonoBehaviour
{
[SerializeField] float bulletSpeed;
Rigidbody2D bulletRigidbody;
PlayerMovement player;
float xSpeed;
void Start()
{
bulletRigidbody = GetComponent<Rigidbody2D>();
player = FindObjectOfType<PlayerMovement>();
xSpeed = player.transform.localScale.x * bulletSpeed;
}
// Update is called once per frame
void Update()
{
bulletRigidbody.velocity = new Vector2(xSpeed, 0f);
}
void OnTriggerEnter2D (Collider2D other)
{
Debug.Log("wazzup?");
if (other.tag == "Enemy")
{
Destroy(other.gameObject);
Destroy(gameObject);
}
}
void OnCollisionEnter2D(Collision2D other)
{
Destroy(gameObject);
}
}