![]() My gut feeling is that it's not scalable and is a bad idea. To be honest, I have never seen a physics driven animation solution that did what you're trying. I can probably tweak and fix this, but it feels very hacky to do it this way and I don't like it.Ī note on snapping: I tried my own 'snapping' implementations with the regular physics engine but I always ran into jittery behavior. If my character travels at a high enough angle they can get caught on the outer lip of a straight edge, as seen here: EXCEPT, when I try to transition from code slopes to the regular physics objects. So far this has worked almost flawlessly for me. I also use this logic to snap them downwards, resulting in a nice smooth effect. If my character is inside of one (that is to say, their bottom edge passes below the angle of any of the existing slopes), I snap them to the top of it. After the physics code fires I manually loop through my defined slopes. In this method I completely remove slopes from the physics engine and store them as just lines in code. My Method: Treat slopes as code-only, Character is a rectangle It removes the ability to have discrete on/off platform mechanics. ![]() In this example the character can basically sit at an angle on an edge without falling off. This still does not account for snapping, but more importantly, it allows for weird edge scenarios like this: By connecting a wheel object to the bottom of your character (and locking the character in the upright position) you can safely roll over any surface. This is a very common solution I have found online. Method 2: Character is a rectangle + wheel (or capsule) This method also does not account for downward snapping (when you want your character to 'snap' to the angle of the slope as they move up and down it) You can disable the friction on the slope, but then your character will slide. Unfortunately when you move a rectangle into an upwards slope, it gets stuck because of basic friction. I think this is the first thing that comes to everyone's mind when they think of discrete 2d collision. Let's look at a couple of common solutions: I am currently working with the Box2d physics engine in Unity. I have my own solution but I want to get some input from others. Slopes and I have never gotten along very well when it comes to 2d platform games, I tend to be pretty picky.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |