So I have this endless runner game I’m making
And with the movement I’ve run into a problem
I use AddForce for Rigidbody to make it jump
And change the size of the collider if you slide
But I wanted to have a movement for when you slide mid jump and it immediately falls to the ground and slides
But it works like once every 10 jumps idk why
thanks in advance
when this type of errors happens, stuff sometimes work sometimes not is because your code is not structured correctly and parts of it conflicts with other parts interrupting or preventing a certain code part to run. this happens especially when dealing with user input and trying to jungle many if else statements.
to fix these issues that will make go crazy if you are not aware of them you need to learn about game programming patterns. unity create a very good book resource that teaches how this works in unity, I wish I had this book years ago.
yes is quite a time challenge to learn this but for any beginner I can’t stress enough how much wasted time you will avoid in the future if you know the information from this book
Sounds like you wrote a bug… and that means… 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.
Posting the code (in code tags) can also help us point out where the issue might be.