I have two objects. Player and a ball. I have an invisible wall that needs to prevent the player from entering the goalie area but only the ball can pass through. How do I use the isTrigger function where only the ball can pass through the wall and not the player? I thought I did something right but if the player touches the wall first before the ball, the isTrigger becomes disabled which means the ball cannot pass the trigger wall. I am new to coding so please don’t make fun of my amateur coding skills lol.
Hmm, im’m not sure if this will help you or not, but perhaps coming at this from a different direction might help you. So, if you have a ball that should be allowed to pass through the collider, but the player can not, you may want to look into setting the collider onto a layer, for eg “PlayerBlocker”. Than, your ball could be on a layer “Ball”, and the player on a layer “Player”. In the physics collisions / Project Settings, you could configure the PlayerBlocker to only interact with the Player, this way, the ball can always pass through, but the player can not.
Then, if for some reason you need to STOP the player, and disallow the ‘throw’ because the player touched the collider, well, that should be easy enough too.
I’m probably not interpreting exactly what you are trying to do, but maybe this will give you some ideas beyond the traditional trigger.
First, set your player onto a Layer named “Player”. And your playerBlocker onto a layer named PlayerBlocker (or whatever), and your ball onto a “Ball” layer. You can create new layers from the inspector. Then go to Unity Menu / Edit / Project Settings / Physics. From there, you will want to have the Player and PlayerBlocker tick marked to recognize each other, and you will want to set the ball to not (no tick mark) interact with the playerBlocker.
It’s really rather easy to setup, if you have any troubles, hit me up on discord. JD#1539