I’m going to try and explain this as simple as possible.
I am creating a 2D style game w/ Parallaxing. I have multiple layers in order to simulate the 3D environment and everything looks great. The objects that “collide” are on the same layer.
In parallaxing, the way you simulate the 3D-ness is to keep the the player stationary and move all of the layers to simulate movement. This is the problem.
When the player moves from point 0,10,0 to 20,10,20 (the Y is fixed for the 2D) in the game, its not the player that is moving… its all of the backgrounds.
So, in reality, this is what it looks like via movement:
- Player is stationary at 0, 10, 0
- Layer 1 moved at normal speed and is now at -20, 0, -20
- Layer 2 moved at a slight percentage higher than Layer 1 and its at -21, 5, -21
- Layer 3 moved at an even higher percentage rate than Layer 2 and its at -22, 10, -22
With all of this, I have environment objects that “live” in Layer 3 but their positions are based on the Layer’s position… not the players. The objects move with the layer due to the fact that the Layer is just an empty game object that is the parent to everything that lives in that layer. I just move the empty game object’s position… nothing else.
So when a Layer 3 object collides visually with the player (they both occupy the same space) the Unity Engine’s collision detection does NOT trigger any kind of collision because neither the Player object nor the Collided-with object moved. The LAYERS did.
If the game is running and I “move” via the parallax way of doing things such that the Player object resides in the same space as a collidable object, no trigger or collision will occur. But, if I literally move either object in the Unity UI in any direction via the object’s position slider (mouse grab to increase or decrease the value)… bam! I get collision detection.
It seems as if the Unity collision detection doesnt deal w/ arbitrary object bounds so much as object movement? I really dont know any other way to describe it. And I have no idea how to solve the issue.
Any suggestions?
Thanks!
PAR