Search Unity

Question 3d Colliders and Triggers

Discussion in 'Physics' started by zdparathyras, Jan 10, 2022.

  1. zdparathyras

    zdparathyras

    Joined:
    Jul 10, 2019
    Posts:
    3
    Hello guys i am kind of a newbie in Unity and i have a problem in the game im Creating. In my game i drag and drop several objects on top of static gameobject in which i have created multiple child objects with box collider (triggers) and i have a script to manage these collisions.Of course what im doing isnt working. The problem is that i want to know which separate childs the object i dropped has hit and then do some code to position it.
    The objects i drop are electrocomponets and the other object is breadboard and each hole in it is a separate child trigger.How can i get all collisions to trigger and after that run my code? I have tried making the parent a trigger and call OnTriggerEnter to or giving it a collider and call OnCollisionEnter but both of these created timing problems. Any thoughts?

    Screenshot (58).png Screenshot (57).png Screenshot (56).png
     

    Attached Files:

  2. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    326
    If the board is not moving and you obviously know the position of the components you are placing, why would you use triggers to identify where on the board the component is? Sorry if I am missing something here, but it looks to me like you already know the component position/rotation values, so you must already know which holes they are in (by a simple position calculation)? Intuitively this does not look like a problem that wants to use physics and triggers for a solution.

    I think you may get a better answer to this question from the scripting forum, where no doubt someone will suggest an elegant solution to tracking the state of your circuit and how to process it.