- Home /
check collision of object B from object A
So, currently what I'm trying to do is have a character controller(working on its own) that I can swap the mesh (in a child).
My problem comes when I get to my jumping, I debounce jumping by using OnCollisionEnter
, a bool and if statements. But if my script is in object A (player) I cannot use the void OnCollisionEnter
to check collisions on object B (mesh)..
tl;dr: How would I check object B's collision using a script on object A
//attempt 1
mesh.collider.OnCollisionEnter()
{is_jumped = false;}
//attempt2
void Start(){
col = Transform.GetComponent(mesh.collider);}
col.OnCollisionEnter()
{is_jumped = false;}
all other attempts have equally failed... edit: using c#
Could you post what you've attempted? I'm not sure what is "object A no code"
Answer by tanoshimi · Nov 29, 2014 at 10:20 PM
tl;dr; You can't. Collision messages are sent to the OnCollisionEnter() handlers of the two gameobjects involved in a collision, but are not generally accessible to any third party script.
The solution is to create some sort of custom centralised collision manager, and get objects to update that when they are involved in any collision. This collision manager can then be queried by any other object.
I think my solution will simply to raycast to detect the ground, ty
Your answer

Follow this Question
Related Questions
Collision with no contact? 2 Answers
Unparent object on collision? 3 Answers
Transform collider not detecting collision on rigidbody collider 2 Answers
onCollisionEnter function called from another object. 1 Answer
Change Direction on Collision 6 Answers