How to detect Collision/Overlap between a BoxCollider2D(trigger) and PlaftformEffector2D ?
Hello.
I'm building a 2D game, were ladders contains "BoxCollider2D" as triggers, and floating platforms contains also a "BoxCollider2D" but with an PlatformEffector2D wich remove the "trigger/collide part".
I need to detect if my Ladder collide with any Platforms to avoid such cases, but anything i've tried failed.
public Collider2D col;
void Start()
{
if(col.bounds.Intersects(GetComponent<Collider2D>().bounds)){
Destroy(this.gameObject);
}
}
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.tag == "Ladder")
{
Destroy(this.gameObject);
}
}
void OnCollisionStay2D(Collision2D collider)
{
if (collider.gameObject.tag == "Ladder")
{
Destroy(this.gameObject);
}
}
void OnTriggerStay2D(Collider2D collider)
{
if (collider.gameObject.tag == "Ladder")
{
Destroy(this.gameObject);
}
}
void Update()
{
if(this.GetComponent<Collider2D>().IsTouchingLayers(LayerMask.GetMask("Ladder"))){
Destroy(this.gameObject);
}
}
I tried with any of these case on my Platform, but it doesn't work, is there any way to detect such "Overlapping/Collision" between a BoxCollider2D as trigger and another BoxCollider2D as PlatformEffector2D ?
Thanks in advance^^'.
Answer by Bakudan · May 10, 2018 at 10:27 AM
I finally found how to resolve this issu.
I needed to add a Kinematic Rigibody2D on my platform to be able to be detected by the trigger Ladder.
Your answer
Follow this Question
Related Questions
Can I use a NES controller for my Unity games, if so how do I program it? 0 Answers
How to put my Unity made game into Android Studio phone app ? 1 Answer
Error after compiling WebGL 1 Answer
Facing problem in saving and building the project 0 Answers
Why can't I export my game to windows? 0 Answers