- Home /
How do I detect multiple collider in different positions in the same frame?,How do I detect multiple obstacles in the same frame?
I'm trying to write a pathfinding algorithm. However I'm having trouble about detecting obstacles in the map. My current plan is writing a normal pathfinding class without inherite Monobehaviour. And the class will calculate and get a list of vector3 during the initiation. That means all pathfinding calculations need to be done in a frame.However I'm having problem with detecting obstacles. My plan is when I take a spot from Vector3, it will detect the 9 position around it. If the position has an collider, then it will ignore that position. I've tried onTriggerEnter and onTriggerExit. But they need multiple frames to update the method so it doesn't work. I've also tried Collider.bounds.Contain(), but it cannot detect the tree collider(I painted the tree using terrain tool). I've make sure the tree prefabs do have a capsule collider. Is there anyway that I can detect multiple collider of different positions in the same frame? Can someone help me with that?,I'm trying to write a pathfinding algorithm. However I'm having trouble about detecting obstacles in the map. My current plan is writing a normal pathfinding class without inherite Monobehaviour. And the class will calculate and get a list of vector3 during the initiation. That means all pathfinding calculations need to be done in a frame.However I'm having problem with detecting obstacles. My plan is when I take a spot from Vector3, it will detect the 9 position around it. If the position has an collider, then it will ignore that position. I've tried onTriggerEnter and onTriggerExit. But they need multiple frames to update the method so it doesn't work. I've also tried Collider.bounds.Contain(), but it cannot detect the tree collider(I painted the tree using terrain tool). I've make sure the tree prefabs do have a capsule collider. Is there anyway that I can detect multiple collider of different positions in the same frame?
Answer by yangyh967 · May 27, 2021 at 08:18 PM
I just realize I forgot using raycast. I use the raycast instead of the Collider.bounds.contain, and it work pretty well now.
Your answer

Follow this Question
Related Questions
Percentage of Collider within a Trigger Area (C#) 1 Answer
Matching an object's size 1 Answer
How to check the place before drop the object 1 Answer
Calculating an object's bounds... 1 Answer
Change Collider Bounds at Run-time 0 Answers