This comment is like 3 years later but thank goodness i found this channel, you're amazing dude.
@troy92175 жыл бұрын
This is the series of videos I've always needed! Thanks so much Matthew!
@scoobynicker3 жыл бұрын
Thank you! Been I've been putting off fixing this exact issue in my game for months. I wish I would have found you earlier.
@user-og6hl6lv7p5 жыл бұрын
Instead you could align a seperate gameobject to the collision surface normal and then use then use that gameobject as a directional reference for your character movement. So if you're on a slope the direction reference gameobject will rotate to match the surface normal, then you move your character while referencing the aligned gameobject, so it would look something like this: fowardMovement = directionReference.forward * vertInput; rightMovement = directionReference.right * horizInput; This way you don't have to constantly apply a ludicrous amount of force to the character saving a bit of overhead.
@rodolf59414 жыл бұрын
THANK YOU!!! This problem gave me brain damage. I tired everything, I mean, everything. Including increasing the gravity. But I never thought about increasing the gravity ONLY when you're on stairs or similar objects. Thank you man, even 2 years later, you're still extremly helpful
@crazecrazie6 жыл бұрын
PSA, if you remove 'if (hit.normal != Vector3.up)', it will fix the jittering on stairs too (with the jump bool keeping the whole thing from breaking after removing that code). Adjusting the slope limit while not jumping will still give you some play room with terrain slopes, i recommend serializing this value.
@DoomVisuals Жыл бұрын
Or instead, have smooth stairs, add an invisible ramp on the stairs, it's smoother.
@NathanTheCraziest2 жыл бұрын
Thank you so much for the proper explanation in a way i could understand, many other tutorials were too hard to understand but yours was very well explained, you deserve more subs
@gr8m8n86 жыл бұрын
I cant believe this worked for me! THANK YOU I looked everywhere and no one actually has a solution as effective as yours!
@Xyz-q9f3 жыл бұрын
Incredible tutorial, worked 1000x better than any other I worked through
@dynamicvoltage97658 ай бұрын
If you're already shooting a ray down, you might as well just set the player to the ground by measuring the distance to the floor. By adding extra gravity you run the risk of changing the speed at which the player moves.
@simpleguyissimple4 жыл бұрын
your channel is so underrated. greetings from the Philippines ! you're the best man.
@nostalgia72112 ай бұрын
Thanks, buddy! Thanks to you, I managed to solve the problem of sliding for surfing.
@PhantomWolf933 жыл бұрын
I had this problem for a long time and your video has been of great help, both to understand the problem and to solve it. Thanks so much :)
@javac91585 жыл бұрын
Better yet, you can "rotate" your move input to follow the curvature of the terrain. Simply find the normal of the ground and do ``` Quaternion rotation = Quaternion.FromToRotation(transform.up, groundNormal); move = rotation) * velocity; ``` and then use the move variable to control the player. This way you don't have to add an additional force when moving on slopes
@Mr.Epsilion5 жыл бұрын
good solution :) thanks Lane
@creasu1244 жыл бұрын
This is a very nice solution I think this is a very nice way of doing it
@melowfx3 жыл бұрын
Hello! I really don't understand how to implement this system into my player controller, could you help me please? I'm struggling with problem so long ( how can I share pastebin, my comment gets deleted)
this tutorial is a good easy fix unless you need to jump while on the slope
@dagmarski41333 жыл бұрын
You could code it so it behaves normal when jump is pressed
@null9876 жыл бұрын
Does the normal return a vector perpendicular to the surface? Very good tutorial, easy to understand and concise! Keep up the good content!
@AcaciaDeveloper6 жыл бұрын
Yes, that is correct. The normal vector points away (perpendicular) from the surface that a ray hits. Glad to hear you enjoyed!
@Rosstail3 жыл бұрын
Thank you, some tutorials explained this for 2D, and the documentation gave another name for the 3D one ^^. After some Vector cross it is really possible to make a character slide on a high pitch ^^
@SonictheHedgehogInRealLife3 жыл бұрын
I'm trying to make the character move on ramps loops walls ceilings any angled slope I have the player rotating by getting the surface normal from a raycast. I can move on flat ground but the player stops when trying to run up the ramps and onto walls
@forcepower71166 жыл бұрын
Please do Crouching next Love this Series so far
@AcaciaDeveloper6 жыл бұрын
Glad to hear it. Crouching and sprinting are planned for the next two episodes.
@WeegeepieYT6 жыл бұрын
yay :D
@scotttrexler99476 жыл бұрын
Saves me from having to ask. Can't wait for these videos... and thank you for the ones you've already done!
@mdthevideogame4 жыл бұрын
Acacia Developer hello Matthew
@zenrepublic973 жыл бұрын
Saved my life, way too good of a tutorial
@iDerp695 жыл бұрын
Incredibly useful video, wow. Thank you!
@RetroAnt34 жыл бұрын
Thank you so much. This ruined my game and you helped me fix it. You deserve much much more Views and Subs
@chikaychhann56285 жыл бұрын
Keep it on, I always watch your videos
@AthosSampaio4 жыл бұрын
Thanks for the tutorial. Clear and very useful!
@unhommequicourt4 жыл бұрын
well i m still bouncing. I just can t jump from slopes anymore with this code
@headrushgaming26144 жыл бұрын
wouldn't this make jumping on a slope impossible if your'e using rb.AddForce or animation controllers and a capsule collider
@bekirkagankaraahmetoglu4 жыл бұрын
It looks like we can use it for climbing on a vertical wall am I right?
@RichardGardnerUK3 жыл бұрын
Why not just apply the force in the direction of the input and slope? It seems like changing gravity is just going to open up a can of worms in the long run. I found the reason for the skipping was because you are trying to apply a directly horizontal force when you are not on a completely flat surface. The same can be said when going up slopes, without the force applied in a relative direction you will find yourself slowing down as you essentially run into the ground.
@SonictheHedgehogInRealLife2 жыл бұрын
howwww
@virtuagames49575 жыл бұрын
Great Tutorial, Thanks a lot, it helped me right now
@samhsmith6 жыл бұрын
My solution for this is to rotate the move force so that it is perpendicular to the surface normal
@justinc26335 жыл бұрын
parallel?
@SonictheHedgehogInRealLife2 жыл бұрын
Howwww
@johni30804 жыл бұрын
Amazing tutorial, but one fix, I think you want to add the slopeForceRayLength to charController.height / 2 and not multiply in Physics.Raycast if statement, line 58
@IT-vy7kx5 жыл бұрын
Thank you! Get this guy out there!
@kovacsbence55214 жыл бұрын
For some reason, moving up platforms makes the code think you are actually not moving? Yeah okay, seems like the problem was with some Animation script. Thank you very much for your help nonetheless!
@CAESAR_IS_GOD_mohammadisaloser3 жыл бұрын
This works until I perform a jump and then it goes back to bouncing? heres my jump code its different than yours if (controller.isGrounded) { moveDirection.y = 0f; if (input.GetButtonDown("Jump")) { isJumping = true; moveDirection.y = jumpForce; audioSource.PlayOneShot(Jump, 0.5f); } } is it just a placement issue possibly ? do I have to have it in a particular order?
@CAESAR_IS_GOD_mohammadisaloser3 жыл бұрын
forget it figured it out had to add an else { isJumping = false; } line after my jump code.
@mrworld84943 жыл бұрын
sooo good i really needed this!!
@94call4 жыл бұрын
Thank you so much!! You saved me a lot of time
@SDFTDusername5 жыл бұрын
can you please teach us that if we are on the slope the camera will face to the slope direction
@maevixie70413 жыл бұрын
When my character is trying to go up a slope, it gets heavily slown down. Going down is fine. I'm using a rigidbody instead of character controller but I think I've managed to edit the code shown in the vid to be suitable for rbs. Any idea what might cause this to happen?
@pandarzzz6 жыл бұрын
Thank you for sharing this informative video!
@yester89463 жыл бұрын
Great video but there's a problem: if I set the slope force to a high number to remove the small bounces, I can't jump when going up until I stop which then would process the jump mechanic. NOTE: I use Brackeys FPS movement tutorial
@LowResDev5 жыл бұрын
This particular method doesnt seem to allow for mid air movement. How could I implement this?
@user-og6hl6lv7p5 жыл бұрын
Have you tried increasing movement forces while the character isn't grounded?
@NeZ3RR4 жыл бұрын
Hi i have a problem with if ((vertical != 0 || horizontal != 0) && onSlope) it shows error Operator '&&' cannot be applied to operands of type 'bool' and 'method group'
@NeZ3RR4 жыл бұрын
oops my bad the && onSlope should have ()
@Berniebud3 жыл бұрын
im having the issue where my character is constantly sliding down even the slightest slope
@jsj05204 жыл бұрын
i of course was working on my own project and didnt have the same code as you but when i went to go test if i have the slope force at 0 my character moves down normal, but if i have it at any number above 0 he starts to bounce down again. idk whats going on but im not complaining XD.
@5_Fallen-3f4 жыл бұрын
Thank you so much. Amazing video.
@AevenIridescent6 жыл бұрын
What i did when dealing with this issue was projecting the horizontal movement into the normal plane of the collider im hitting, simply done with Vector3.Project, as long as a very small raycast hits, so im not floating midair
@SonictheHedgehogInRealLife2 жыл бұрын
yooooo i cant get it to work ive tried doing the same thing
@AevenIridescent2 жыл бұрын
@@SonictheHedgehogInRealLife make a downwards raycast bellow your character, get the normal out of the hit, then use Vector3.ProjectOnPlane using the direction you wanna go and the normal you got.
@SonictheHedgehogInRealLife2 жыл бұрын
@@AevenIridescent I did do this but for some reason it's only working on flat planes. I have a ramp that's smooth like a sonic game and when the rigidbody goes down the ramp it jitters.
@AevenIridescent2 жыл бұрын
@@SonictheHedgehogInRealLife you might be messing up which vectors you're using, try using gizmo.draw to debug the vectors. But if you're making a sonic like game, then the problem could be another one, if the ramp is too steep the raycast could be failing to hit
@SonictheHedgehogInRealLife2 жыл бұрын
@@AevenIridescent could be a possibility My ray cast seems to be working it gets the surface Normal of the ramp successfully. I'm casting the raycast down from the player. The player can rotate successful with the surface Normal. I'm not sure what could be going wrong. Can I see your code if you have it?
@animadoarts51235 жыл бұрын
Will it also climb the hill.. without resistive force
@louislemur3 жыл бұрын
OMFG EXACTLY WHAT IM LOOKING FOR
@AgressivePigeonАй бұрын
You are a godsend.
@m.h.kstudio17403 жыл бұрын
this tutorial is a good easy fix unless you need to jump while on the slope how to jump in slope ???\
@노성엽-y2k3 жыл бұрын
Can you even climb trees?
@beandevelopment95034 жыл бұрын
where did u go I love these vids there ultra helpfull
@aberrantcurse85515 жыл бұрын
how do you detect which way the slope is facing?
@aberrantcurse85515 жыл бұрын
nvm i got it
@xdplai31904 жыл бұрын
Can anybody help me i have tried this but its not working. I found out the mistake by printing hit.normal which is always giving (0, 0, 0) even when i am on slope
@dylanfoster1864 жыл бұрын
your raycast isnt hiting a collider. Make sure the raycast length is long enough to reach the ground.
@connorc17425 жыл бұрын
How do i prevent the slope force from weighing down my jump height when walking???
@connorc17425 жыл бұрын
And this won’t make my jump height less when walking?
@CornRecords9725 жыл бұрын
@@connorc1742 Lemme explain it's because the additional gravity for slopes is only applied when the person is on a slope and not jumping so as soon as the player jumps the extra gravity is removed
@connorc17425 жыл бұрын
@@CornRecords972 Wait can you message your full script? im kind of confused on where to put this
@CornRecords9725 жыл бұрын
@@connorc1742 Rewatch the tutorial and look for where he put the code then compare what he types to mine. If I show you everything you wont learn.
@chaos4living6764 жыл бұрын
Doesn't work for me, it say that there is no definition for height and that is not accessible extension method 'height' accepting a first argument of type 'PlayerController' I'v read your code and don't understand how you can do but .height seem to be shitted out of nowhere as far I am concerned. Tumb down
@unhommequicourt4 жыл бұрын
i think you just misspelled height. i don t have compilation error
@iR3dy3 жыл бұрын
will this work for third person
@durr4n3715 жыл бұрын
it says for me: Invalid expression term '&&' any help?
@TheGordonFryman5 жыл бұрын
Hey! Are you still getting this error? If so, can you show me your script?
@durr4n3715 жыл бұрын
@@TheGordonFryman hi, I was getting the error but I've since changed interests in game design and have uninstalled unity
@justinc26335 жыл бұрын
@@durr4n371 hahaha
@dcat1832 Жыл бұрын
how to jump?
@alextang52686 жыл бұрын
please make a vid on how to get the player to be able to move while in mid air
@pixelfiltergames23106 жыл бұрын
alex tang why that is not even a thing that needs any code to not make him move in mid air is harder
@fd83734 жыл бұрын
A year ago this work for me but now it do´nt . Any ideas ?
@unhommequicourt4 жыл бұрын
i don t know i tried this today and the code does nothing i m still bouncing.
@u.s70726 жыл бұрын
great series, looking foward the sprint / crouching
@pixelfiltergames23106 жыл бұрын
† † † U.S come on for sprinting increase speed and change animation crouch decrease speed change animation
@322ss6 жыл бұрын
Thanks for the videos! Interesting approach for grounding player in slopes, but would this work for capsule collider with physics movement as the floor could be slippery? Also, couldn't you just add the downward force whenever not jumping? Another idea - if you really want to glue the player to the ground, have you tried alternatively to just move the character downward based on raycast hit?
@AcaciaDeveloper6 жыл бұрын
Hi, good questions. "but would this work for capsule collider with physics movement as the floor could be slippery?" I'm unsure about how rigidbody physics would react exactly since I've built this tutorial for a character controller (that doesn't interact with Unity's physics system). If you're adding custom physics materials to your ramps and trying to pin rigidbody objects down onto it, then that could be something good for you to test out to see what does and doesn't work. "Also, couldn't you just add the downward force whenever not jumping?" Yes, you can do that, but it could introduce unwanted side-effects depending on how the controller is being used. I'd prefer to implement some extra computation to make sure that I'm only applying additional downward force when it's needed. It's also the case that if the player simply walks off a ledge, they will fall to the ground very fast since the space bar was never pressed to trigger the jump. You'll probably have to do an additional check to the isGrounded boolean on your character controller to solve this issue, although from my experimentation, this caused some other problems. "if you really want to glue the player to the ground, have you tried alternatively to just move the character downward based on raycast hit?" I've tried setting the player controller's position directly to n number of units higher on the y axis than the hit point on the floor. This caused jittering as the player walked onto and off the ramp, and the movement on the ramp seemed slightly more sharp and sudden than it should be.
@joshuamason22275 жыл бұрын
what happens when you jump on a slope while walking though?
@lilcatfriend45755 жыл бұрын
the whole thing poops out IVE BEEN TRYING TO FIX IT BUT CAN'T THINK OF HOW TO DO IT
@joshuamason22275 жыл бұрын
@@lilcatfriend4575 I think to fix it you need to abandon the whole add gravity thing and try some new methods. Just a suggestion, I ain't no expert
@illusen10205 жыл бұрын
I just threw the "if (verticalInput != 0 || horizontalInput != 0 && OnSlope())...." into another "if (!isJumping)" because if I'm jumping I don't care if there's a slope beneath me or not
@damgaronfire5 жыл бұрын
5:00 the heck are those signes
@ksew92695 жыл бұрын
OR operator
@WhereisYunoGasai5 жыл бұрын
damgar Video Jeux signs*
@technoo48913 жыл бұрын
learn c# first before trying to learn unity, fucks sake..
@damgaronfire3 жыл бұрын
@@technoo4891 dude that was 1 yr ago y you booly me
@goncharov0006 жыл бұрын
awesome stuff
@Dudi4PoLFr6 жыл бұрын
Could you do a episode about Crouching, Sprinting/Walking?
@AcaciaDeveloper6 жыл бұрын
Crouching and sprinting are planned for the next two episodes.
@Dudi4PoLFr6 жыл бұрын
@@AcaciaDeveloper Great news! Thank you for your replay.
@i3m1r6 жыл бұрын
please make running, incline and creep
@mdthevideogame4 жыл бұрын
Hello Matthew
@shalluxi71845 жыл бұрын
Thank you!
@joegrizzly9995 жыл бұрын
Or you can us a invisible collider for a smooth slope game do that for a easy fix