2D Game - Get collider name
Hello everybody! I want to create a 2D platform game, but I have a little problem ... I've put names for all my platforms : "platform0", "platform1", ... but in the function OnCollisionEnter2D, using collider.gameObject.name
, I can't get the name of the platform, but I get "Collider", "Slider", ...
How to fix it ?
(sorry for my bad english ^^)
If the following script is on your player object:
void OnCollisionEnter2D(Collision2D collision) {
Debug.Log(collision.collider.gameObject.name);
}
it will print the name of the gameObject you have collided with.
I've already used collider.gameObject.name
but i get "Collider" or "Slider" ins$$anonymous$$d "platform0", "platform1", ...
Your answer
Follow this Question
Related Questions
Constant Collision 1 Answer
detect a trigger one time per collision 2 Answers
Bounds and extents of a tilemap collider across differing y axes, Tilemap collider bounds 0 Answers
Pipe Game Water Flow 0 Answers
Collision detection 1 Answer