- Home /
How to compound collider in a script?
I was trying to make 2.5d platformer player controller by myself. The goal is making the player controller similar with the one of Megaman X series, which allows slope detection, wall jumping, dashing, insta-death by crushing, and other various features.
Anyway, I just began my first step by constructing four child components(which would be located on player's top, front, back, and bottom) and giving to each of them nothing but transform and box colliders. And I'm trying to add another piece of code to them, but scripting isn't so easy.
Here is what I want to perform.
In the script of each child components, the method OnCollisionEnter(Collision collision)
would send a message to the parent(player) component that contains collision
and the info of this child component which collider is collided. So I want to know what message, or mechanism could be useful to send collision info to parent component.
In the script of the parent component, it would receive the message from 4 child components and do some action according to the message info. I couldn't advance it because I'm still curious where should be the child components declared, and how do I match each child components with colliders of scene editers...
I'm not very good at Unity, so I'd be happy if I could get some tutorial sites or videos. Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220613175347im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Instantiate at Child Object 2 Answers
how to find the child of an object i hit with raycast 1 Answer
Moving certain sprites in my animation causes weird slingshot effect 0 Answers
can i rotate a child object around the roots local axis using the childobjects reference point? 0 Answers
How do I reference the cameraEye in another script 0 Answers