Im in school for Game design, and as a side project I have been making Pacman in unity 2d. Everything about my pacman game is flawless so far, except my pac dots dont work. For some reason, checking “is trigger” is not turning off the physics collision detection, and my pacman walks right into them and stops like its a wall.
I have code that uses OnTriggerEnter to destroy the pac dots and add 1 to the score, but since my pacman cant enter the collider, the dots just act as walls. For some reason when I check “is trigger” on the pac dots, they still retain their physics collision detection.
Can someone help me figure out why this is happening?
Check to see if you’re getting an OnCollisionEnter2D callback instead. If so, you’re either not setting it to be a trigger or another collider is stopping it getting to the trigger in question.
Make sure You players has a rigidbody2D and a collider2D(circle as it pacman), your dots or pills as they are officially called will also need a circlecollider2D you MUST only use 2D or 3D, you CANNOT mix these together it will not work.
I have a rigidbody2d on on my packman, and my pacman works perfectly. He collids with walls, and the animations work in all directions.
While the collider in the photo is a box collider, I have also tried it with circle colliders. My Pacman runs into them like its a wall. Hitting is trigger does nothing sadly.
I think my issue may be the fact that i made this on my mac. I usually do my unity work on my PC.
Ive even tried just putting an empty game object into the scene, making a circle collider on it and checking is trigger. It still acts as a wall even with just a trigger collider selected.
If you can provide me with the project then I’d be happy to take a look at it for you. Either provide me with a download link or submit a bug case and give me the number.
I will get you a project as soon as I can. I have transfered most of the project over to my PC to test to see if it was the mac, and I get the same issue. Even when I put an empty object into the scene and put a box or circle collider on it, if I check is trigger my pacman still collides with it.
Here is the package on my mac, its more complete than my PC version. I have a trigger test thats just an empty object with a collider attatched, but checking the istrigger button doesnt do anything for me.
is returning true only when the first collider your linecast hits is the pacman. When you linecast and hit a pacdot your valid method is returning false (and your destination isn’t valid) because the first thing it hits isn’t itself. I’m curious to know why you’re not relying on unity’s physics to deal with maze collision?
Thank you! That worked, I can now pick up my pills. I didnt know you could toggle the bool that way, ill make sure to remember that! I was just following a tutorial I found on google. Guess the code was bad.
I was just following a guide online, I guess the code was bad. After removing that check and just using the basic collision, I found that this also made the triggers work properly but then when my pacman hit a wall, it would get stuck on it. I suspect thats why the guide was using the line cast I guess, cause it avoided that problem.
I would love to know how to do it without a line cast, that would be awesome too, but like I said I am still in school in learning. Part of why I did this was so I could better understand the basic fundamentals of how movement and stuff works since my school always gives us templates with that stuff included.