# Simulating physics collision and movement, like N++

Hi,
how would one approach this kind of movement?

Using Unity's physics is completely out of the question, I suppose.
The main problem would be the slopes. The player should be able to run up slopes, but depending on the slope degree it should be pushed backwards and downwards.

I was thinking of using a collision system based on a grid, since what I have in mind uses tiles anyway. I would check all the player adjacent tiles and then start from there. If I'm moving right and I'm entering a 45Âş tile, then I know that's a slope I should be able to climb, but also one that pushes you downwards at a certain force. If it's a curved convex or concave tile, the same, etc.

The sprite (and the collider, which I think the best fit would be capsule/circle and not box) should rotate together with the slope as well.

How would you approach something like this? I'm not asking for code (although if you know of any asset, let me know), rather how you would manage the collisions with slopes (the velocity, the jumping, etc. are much easier to do, the puzzle are the slopes themselves).

[quote=â€śArkanisGathâ€ť, post:1, topic: 912127]
Using Unityâ€™s physics is completely out of the question, I suppose.
[/quote]
Why? By â€śUnity Physicsâ€ť do you mean a Dynamic body? Because youâ€™re better describing it as that. â€śUnity Physicsâ€ť means using any of the components provided, Rigidbody2D, Colliders, Joints, Effectors and collision detection including physics queries.

[quote=â€śArkanisGathâ€ť, post:1, topic: 912127]
How would you approach something like this?
[/quote]
You need to write or use a controller. The â€śUnity Physicsâ€ť system provides you with everything you need including a wealth of physics queries.

A collision with a slope isnâ€™t a specific case. A collision is a collision. How you move after a collision is all up to you. For instance, this example of Kinematic motion where you â€śslideâ€ť along surfaces can be seen here:
https://www.youtube.com/watch?v=dNXJSLJgVGw

In the end, Kinematic motion is just queries to detect your environment then you applying movement.

2 Likes

Adding to the great stuff MelvMay posted above, here's a video about making a custom 3D physics character controller to get the feel the guy wanted:

Yes it is 3D but 100% of what he suggests is applicable in some way to 2D physics.

That guy has a ton of other great custom physics devlog videos... really good stuff.

2 Likes

btw, I wanted to add that this'll become crazy easier in 2023.1 because there's a bunch of improvements to physics queries and a new physics movement feature that allows you, amongst other things, to move/slide along surfaces automatically. This can make creating character controllers much easier.

You can read more here:
https://discussions.unity.com/t/900699

2 Likes