- Home /
Preventing rigidbodys from jumping on a tiled map
hi, i have a map that is created using cubes that is generated during runtime. The player moves using the physics system, and looses health depending on the impact of the collision. The problem is that when the player slides along the map across two tiles, the player jumps as if there was a gap between the tiles or that they were not aligned. The positions of the tiles are correct, meaning that there should be no gaps. This can reduce the players health. Is there a way to fix this issue or a way around it? would it help if they were slightly overlapped?
Would it be an appropriate fix to constrain the Y position?
The player still needs to move on the y axis for intended jumping and gravity. Sorry, i didnt specify the movement of the player.
Work around is probably the best way. Physics is complex, the location of an item in a 3D, or even 2D space is based on lots calculations so expect it to be a little twitchy. With lots of boxes edges will get out of alignment.
Can you place a collider just slightly over the top of the all the cubes at that level to smooth out edge detection to just that collider. Not always easy to do I know but the best I've got at the moment.
EDIT
No problem, it's a complex situation. No I didn't mean a massive collider for each height level, you're 100% right that wouldn't work and cause a whole heap of problems. Although my "random thoughts" $$anonymous$$d just thought "what if you only enable the colliders if they're below the player and a raycast hits a floor item just below the player".
Damn that wasn't what I wanted to write, it might work but only just thought of.
What I was originally going to say is, calculate the area of each level based on the cubes size and their size and set the collider size accordingly.
so have a single collider for each level of the map? if so i dont think that it is suitable as it would not allow different objects be identified? wouldnt this prevent actions (such as death or increase jump height) be identified. or is there another way around, or have i misunderstood the fix? It seems like a good fix for a game with few platform types. Again, sorry for the lack of information.
Your answer
Follow this Question
Related Questions
Why wont my character jump? (using rigidbody and addForce) 1 Answer
Cannot move and jump with rigid body. 0 Answers
Rigid body floating the air when I jump at a wall... how do I fix? 2 Answers
Jump forward then back initial position 0 Answers
Changing the speed and accelleration of a jump using the built-in Physics Rigidbody engine in Unity? 0 Answers