Hi there Unity Community,
This is my first question here as normally I have been able to search existing forum threads for my answers.
It is really quite a simple problem but sometimes simple problems are the most annoying to deal with for a new game programmer such as myself.
So I am currently using nothing but cubes and spheres as my game objects. I am attempting to learn how to make all the objects in the game interact together as expected before I really try to polish the graphics/story/etc. My player is a cube sized to (.5, .5, .5). The ground environment my player is interacting with is simply a series of cubes sized (1, 1, 1). I am not using any custom scripts (standard assets/etc.) as I thought it would be a better learning experience to try to use only my own scripts.
My goal is to have the ground cubes interact with the player based on certain variables in the game. For example right now I want certain cubes to heal the player over time, and I want other cubes to damage the player over time.
Everything seems to be working OK, the different ground cubes do heal or damage the player as expected. The problem is that the collision is not consistent. There are certain spots or “dead zones” where the player cube will stop being affected by the collision. These locations are usually in the middle of two cubes. Let’s say there are 2 healing cubes next to each other if the player is standing directly in the middle, the healing affect may stop, when the player jumps and lands it will resume, but a simple back and forth motion to the same spot will cease collision detection. This problem can be isolated to the individual cube interaction by simply stretching a cube to be sized (10,1,1) instead of (1,1,1). This allows the player to maintain collision as expected while walking over the entire 10 meters.
But there must be a way to make the collision work in a precise manner when intersecting collisions? Currently the player is a Rigid Body with a Box Collider. The ground is Rigid Body with a Mesh Collider.
All I want is an accurate way to detect collision so that I can have environmental areas with unique and consistent effects. For my future game ideas my current result is unacceptable. Right now I am simply using OnCollisionEnter and OnCollisionExit (attached to various surfaces) to trigger the interactions with my player object.
Is their some other method for more accurate detections? I am not sure if the problem is my scripts since I am a novice programmer, or if it is actually the Unity Engine that has this limitation?
I would rather avoid writing complex scripts for something that seems like it should work properly within the Unity Tools I am currently employing. I am not sure that even more complex scripts would solve this problem if it cannot properly detect OnCollisionEnter and OnCollisionExit on identical and adjacent objects.
Any help or advice would be greatly appreciated.