I have a shot that gets fired from a turret which needs to be able to hit multiple targets (once it hits one target the target disappears and the shot should continue in the same direction with the same velocity and can continue on and hit others). My issue is that the targets I currently have are triggers which can run into obstacles, but since they are triggers they simply pass through these obstacles. If I remove the trigger then they correctly run into and bounce off of obstacles but then the shot bounces off of them after hitting them rather than continuing through. So my question is how do I allow shots to hit targets and continue through them after hit while allowing targets to hit and bounce off of obstacles?
Asked
Active
Viewed 37 times
-1
-
You can have a proper collider for the targets so they can interact with the walls. Then, have a separate trigger for the targets on a child object set to a different raycast layer which only your shots use. No idea if this is good practice or not. – code11 Nov 22 '16 at 19:13
-
1How about having the projectiles use raycasts/spherecasts ahead to determine a collision with a target, rather than having colliders on them? This way, they can detect when they're about to hit a target, but won't physically interact with them. (Depending on how fast they move, you may need to do this anyways to ensure they don't "skip" a collision between physics frames.) Using this approach, you can just put regular colliders on the targets so they are blocked by obstacles. – Serlite Nov 22 '16 at 19:20
1 Answers
0
Thanks for the answers you guys, that definitely helped me go in the right direction. I ended up using Physics2D.OverlapCircleAll with the origin point being the center of my shot which returns a list of 2D Colliders that the circle encounters. Then I check the tag of each game object in that list to see if it's an actual target as opposed to an obstacle.

coe720
- 84
- 2