Slope physics

Yo, I wanna create slope physics simmilar to how Sonic controls in the Classic/Adventure games but I’m havin a bit of trouble(yh this is a lot harder than I planned hehe) but I ain’t givin up so what do y’all make o this)

That’s not how troubleshooting is done. :slight_smile:

Try this structure:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you are unsure what is going wrong, that means it is… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.

Also, for code posting, use the proper embed commands at the top of the window. Photographing code is not a thing.

1 Like

Thx bro! Will do

K I’m back with screenshots n context.

Now my process here was aided by chatGPT and this one video https://youtu.be/qgJ_x32Dnxo?si=qT7Wz73ibl_0ixH6
My goal was to first align the player to the ground by aligning him to the normal of the ground and then smoothly rotatin him to look natural. I also did a groundcheck using a raycast. These seemed to work satisfactory though could use a bit of tightening. Then in the HandleMovement area I tried gettin the angle of the slope, and the forward plane projection. Vector3.dot was supposed to get the forward plane projection and then I could use if statements to check if the player was up or down hill usin the forward plane projection, if uphill a force would cause it to decelerate and the opposite for downhill. And there would be a lowest speed reachable goin uphill and then a top speed goin down hill. Now for problems, this barely works, my player isn’t consistently influenced by the slope and when he does it’s pretty buggy, he doesn’t smoothly go on slopes and a random force doesn’t let him go up hill. He also doesnt maintain speed so I’d really appreciate advise from anyone. For ref I wan’t this games physics to play like Sonic Mania, Adventure, Superstars, basically Classic 2D Sonic games. Thanks

Then please do ^^. Don’t post screenshots of code. Most people use dark mode so those white screen stuff is hard to read. Also nobody can copy any of your code to do any tests on their own. We would have to retype everything. It also makes it impossible to find this question when someone has similar code.

1 Like