Sebastian. Your 'Physics.SphereCast' is missing the 'maxDistance'. In the Unity's documentation, you can see that the 'layerMask' comes after the 'maxDistance'. You're feeding your 'groundLayer' (LayerMask) (that get's casted to 'int' by the 'LayerMask' operator). In the end your 'groundLayer' value for Unity IS the 'maxDistance'.
@@SebastianGraves I've double checked all available functions/methods in Unity's Physics class, there are no such overrides. The 'layerMask' always comes after the 'maxDistance'. Plus, see the Unity's documentation.
@@SebastianGraves Sorry. I was not aware of the C#4 feature for the 'Named and Optional Arguments' aka 'out of order' default variables. Looks dangerous... It seems that in your case the 'maxDistance' would simply get it's default 'Infinity' value. Thanks for your hard work. Really love your tutorials.
@@SebastianGraves I did a bit more reaserch. There IS a problem as I've explained regarding the missing 'maxDistance'! Here is the proof: Your 'groundLayer' mask is using 'Default', as an 'int' it would be equal to '1'. Try and draw a sphere of the SphereCast collision 'hit.point'. Comment out your gravity code and try to move the player character in the Unity editor while in Play mode. You'll notice that the SphereCast would only detect collisions that are in the distance of '1'! Additionally, while in Play mode you can try and change your 'groundLayer' mask in the editor and you will notice how the SphereCast hit.point results will change when the player character is moved by mouse in the editor. So this is not even the case of C#'s 'Named and Optional Arguments', as in this case the 'maxDistance' would be 'Infinity' and your code logic would not work at all. ;) Hope this helps.
@@GGodis The layer identification being an int makes sense. I will re-pin the comment, for others to see! Thank you once again for the insight. I probably would not have noticed unless I revisited the series :^)
This is late but others down the line should find this useful I found personally this video needs a few fixes to work as shown in the vid: 1st- physics spherecast should be as follows: if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.Down, out hit, 0.5f, groundLayer) 2nd- on the grounded AND interacting if statement it should be as follows: if (!isGrounded && playerManager.isInteracting) 3rd- my problem was it would not exit the animation cycle no matter what so I never regained control of my player (ability to move again etc.) to fix this I added one extra line of code to stabilise: underneath inAirTimer=0; and isGrounded=true; add in this short line as follows: playerManager.isInteracting = false; (doesn’t need explaining I’m sure this line explains itself)
Hey bro it seems which you have mentioned is right, however there is one issue that is when starting its keeps on looping in falling animation, so it seems we have to add this line on : Void Awake() { isGounded = true; } so that the falling animation doesn't loops the player falling when it start.
Guys in order to make it instant to switch to landing animation, on the transition from falling to landing uncheck the "Has exit Time", and add the condition "isInteracting" to true
First of all, great tutorial. Thanks for your amazing work. I had a problem with the falling animation and i am seeing many people having a similar problem in the comments. In my case the solution was simply modifying the transition from falling to landing. I unchecked the "has exit time" on this transition, and added "isInteracting" bool as a condition for this transition and set it to "true". This solved the problem. However i must give my warning, i am not an expert in unity, so this is just something that worked for me. It might work for you, but there is a possibility that this is not actually a good solution. So take care if you want to apply it.
if your land animation play in the air even if player is landed then here's the fix --> on your Animation go to "root Transform position Y" and change it from Original To Feet
to anyone who desires a smoother transition between landing and the locomotion, play with the speed of the landing animation and instead of the return function activating when an input is active, have it activate when the player isnt grounded. I also added my animations to the base layer and connected them to the locomotion, although im not sure how much this impacted the overall smoothing of the animation.
To all the people who get stuck in land animation, just check in your base Layer (Animator), and if you have a land animation just delete it. You just need one animation on the override section. Because if you got the landing animation in double it will get stuck playing it. Hope it will help.
for anyone whose character is stuck : change your raycastheightoffset value to -3 or -4 depending on your character model (if you are not using his model) , the problem for me was that the raycast position was at the center of my character and not at his feet so it was not able to detect the ground at all.
Honestly your videos are better than Unity's and other paid courses. Please keep them coming! Would love to see more movement based content like jumping and parkour stuff.
i love these tutorials your better then Brackeys and you explain things so well thank you so much i am new to unity and working on my first real try at a game and these have been tremendously helping me thank you and try to get the next one out fast im hoping its either in jumping or stamina thx for all the help :)
Thank you for making this basic version. Really helpful for a newbie like me I'm going to be backing the patreon as soon as I get paid at the end of the month
Ran into a couple of problems, I can fall fast now but I've had to push those numbers to the extreme, and I'm still not doing the falling animation just jittering a lot when I lead from the leadge, but when I start my player above the ground it works
Note for anyone having trouble with the landing or falling try these stuff 1.make the capsule collider 2 instead of 1.8 if using low poly man 2. Use play instead of crossfade 3.on the land animation go to root transform position y and making it from original to feet. 😊
For anyone struggling here, I found it best to add a visualizer of the spherecast by using my player's capsule collider as the source of spherecast radius. To do this add two globals at the beginning: public Gameobject sphereCastVisual; // You'll need to create Sphere gameObject in scene and pass it in CapsuleCollider characterCollider; // Character's collider capsule (get the character collider within awake similar to how we get rigidBody `characterCollider = GetComponent();`) Then at the start of your HandleFalling(): RaycastHit hit; Vector3 rayCastOrigin = transform.position; rayCastOrigin.y += rayCastOffset + characterCollider.radius; // offset with the radius of your capsuleCollider to bring up proper distance // Visualize Spherecast Starting Position sphereCastVisual.transform.localScale = Vector3.one * 2 * characterCollider.radius; // changing scale to the diameter of sphere sphereCastVisual.transform.position = rayCastOrigin; My initial thinking of the SphereCast was that it would create a sphere and check if anything is hit within that sphere, but that is not the case. It actually creates a sphere and shoots it along the provided vector for a provided distance and returns true and the hit object if the sphere hits anything along that vector. Lastly, I changed SphereCast to this: Physics.SphereCast(rayCastOrigin, characterCollider.radius, -transform.up, out hit, maxDistance, groundLayer) So in summary, this creates a sphere of radius equivalent to the character capsule collider, centered at the feet of the character (plus the radius of the sphere as set above + given offset), shoots a straight line down (relative to player transform) of distance maxDistance, and outputs the hit object details if anything is hit within the groundLayer. ** Note I used -transform.up rather than Vector3.down to allow for character rotation in future, as I plan to have my character run around planets with local gravity **
Absolutely fantastic series so far. The clear explanations of what you are doing and why is very good. Can not wait for what is coming in the next couple of weeks. Going to start your Dark Souls in Unity series at some point next week. What kind of movement will you be covering next? I would personally love to see the following: Jumping Double Jumping Vaulting Ledge Climbing/Mantling Crouching/Crouch Walking Prone Obviously not all of these but it would be cool to see how you approach one of these mechanics using the New Input System
Ok, after a few hours of trying to figure it out... My main issue was the animation type of my falling and landing animations. You must remember to put them in humanoid mode in the rig tab otherwise they will not play correctly or even not at all
I had some problems with falling and landing animations not playing at all; could still move while falling and finally my model would fall under ground. Here is what I did: - tried every possible solution in the comment section, there is only one suggested fix that worked: if (Physics.SphereCast(rayCastOrigin, 0.2f, -Vector3.up, out hit, maxDistance, groundLayer)) then adding public float maxDistance = 1; - made sure that all spellings are correct (for the bool names) - You have to make a transition from falling to landing but DO NOT assign any conditions AND keep the "Has exit time" boxes checked! - Your falling animation should be looping and landing should NOT - Make sure that your Animator does not have Apply Root Motion box checked - Instead of a Box Collider I used mash collider and my model is no longer falling under ground These steps helpmed me to resolve the issues
I used mash collider on the ground. Also, if you did everything properly but your character is gliding even when you land (run/walk then jump with W key press) you have to add friction to the ground ( friction 1 works)@@jred7333
ANYONE WHO IS USING MIXAMO: - Make sure to make it a humanoid; Animation->Rig->Animation Type->Humanoid (I don't know if everyone knew this or it was just me)
I had to rewrite this code 3 times before I got it working haha, I'm terrible at scripting so maybe that is why.... What I'm trying to say is don't get discouraged if you don't get it the first time and also don't be afraid of starting over. Great tutorial as always!
Im not sure why, but I needed to double my transform y value to get the ground detection working, have been following the series to t otherwise, has this been an issue for anyone else?
They act the exact same, my best guess to why he used "-Vector3.up" is because in a lot *most* game engines, they won't have a Vector3.down, because storing that in the Vector3 class as a static variable or similar uses more storage and is useless, so if you want a game engine focused on being lightweight then you would only have Vector3.up, Vector3.right, and Vector3.forward, and even that some engines dont have, instead forcing you to write your own like "new Vector3(0, 1, 0)" which is equivalent to Vector3.up. Unity brands its self on being accessible to anyone, so forcing people to use weird syntax like "-Vector3.up" can be off-putting, so thats why unity decided to include it in their engine, but this video is more of focused on teaching code and stuff rather than "What is the simplest or most efficient way of writing this code". its the same reason why he basically never uses the +=, -=, *=, or /= operators, because some languages like Python, don't have those.
Hello, I notice this is similar to the Dark Souls tutorial. What separates this from that? Is it a versatility thing or is it more of an update with a generic theme? I like this so far; the falling trigger is a little sensitive so the player falls near walls and when running downhill on a rough slope. Any tips to check for those issues? Thanks.
@@asddsadsad-b8b I did, but it's been so long since I messed with this one that I don't remember exactly what it was. It wasn't perfect though. I believe it had something to do with the if(inAirTimer=0) line, which in my code is if(inAirTimeer>0.1f). Other than that, it may be something to do with the raycast coming from the collider. Either shorten or lengthen the hit distance maybe? Sorry, but it's been awhile on this one. I ended up writing a controller from scratch so I could be sure I fully understood how everything was put together and that only fit what I needed.
FALLING SLOWLY Add the "maxDistance" parameter to the SphereCast Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out RaycastHit hit, 0.2f, groundLayer) STUCK IN FALLING ANIMATION Make sure the player IS interacting before landing. The falling animation sets isInteracting to true if (!isGrounded && playerManager.isInteracting) {
To get same results as in the video, the 'maxDistance' should be not '0.2f', but '1f'. This is because Sebastian was using the 'groundLayer' mask set only to 'Default'. (When casting 'groundLayer' to 'int' it would result in '1'). Unity's 'SphereCast' took Sebastian's 'groundLayer' for the 'maxDistance'. The real 'layerMask' remained 'DefaultRaycastLayers'.
Thank you! I couldn't figure it out. You can also remove RayCastHit hit and replace it with _ if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out _, 0.5f, groundLayer))
Guys, I finally found it out. If you get stuck after you fall give your floor a rigidbody, take off use gravity, and give all freeze positions a tick. It seemed to do it for me
Hello guys I need help my falling and landing are not working its like they keep on looping and it never jumps to empty and when it does jump to empty it is for a very short time
Did you get a fix for this? Mine keeps randomly changing inAirTimer and playing land and fall but it just gets stuck on the first frames and switches between them.
My character is floating and repeating the falling and landing animations again and again and also my character is going up instead of landing. Please help me...
I am having a strange issue with my project for the falling and landing of a 3rd person controller. There doesnt seem to be any immediate issues with my code No errors or warnings however, my character still floats in the air, the isGrounded bool never gets unchecked The animations transitions get stuck and frozen if I force the bool to be false. and Im given no warnings or errors as to why So i have no idea where to start an extra bit of detail i just noticed upon starting the scene, the ground variable is active and set to true If I walk off a ledge, it stays active and I float When I force-ably de-activate isGrounded during play this is what happens within an instant and a split seconf First : Players gravity kicks in and starts to fall normally Second : Ground variable goes from false to true again instantly, even before hitting the ground Third : Player animations play until either they hit the ground or they finish playing. Forth : The player animations then stay stuck frozen in the end state of the animation still no errors from unity or from Visual studio
Im not sure why when im grounded and the animation is playing even though isInteracting is TRUE, the handlemovement/rotation script is working. Is return function not working?
Semi-new subscriber here! Love this series, thanks for making it :). I can’t wait for the next one. Do you have a set schedule for new vids in this series (I.e. once every 2-3 weeks) or is it just whenever you can get them out?
So when I hit play my character immediately starts floating up, then comes down after 30 ft or so and bobs up and down off the ground. in the inspector it looks like its cycling between being grounded and not grounded but i cant find an issue with the code.
Stuff is happening to me as well. I don't know how adding a downward force can do this, but as I move about, my speed slowing decreases exponentially until I can only turn.
When I finished and tested the final thing out, but I ran into two small problems, one (which is not a big deal) the falling and landing animation plays as soon as I start the game, and the other issue is when I fall and then land, the landing animation is slightly delayed and is played a second time after as well
Is there any way at all to allow movement during the falling/jumping? I've tried everything to get freedom of movement while mid-air, but nothing works. I even tried creating separate HandleJumpMovement and HandleJumpRotation methods to call instead of altering the normal movement, but that didn't work either. I really just want to be able to move freely without any frozen rotation or movement, on top of no longer freezing when landing, but I haven't found a way to do so at all and so the movement doesn't feel as reactive or fluent as it could be.
Recreate the HandleMovement() in the HandleFallingAndLanding() but change playerRigidbody.velocity = movementVelocity; to playerRigidbody.velocity = new Vector3(movementVelocity.x, playerRigidbody.velocity.y, movementVelocity.z);
I got an error 01 ( Invalid Layer Index '-1' UnityEngine.Animator:CrossFade (string,single) ) 02 ( Animator.GotoState: State could not be found UnityEngine.Animator:CrossFade (string,single) ) how can i solve this ?
Using this line --> if(Physics.CheckSphere(rayCastOrigin, 0.2f, groundLayer)) will give better results than this --> if(Physics.SphereCast(rayCastOrigin, 0.2f, groundLayer, out hit))
I am having a few issues despite doing the code correctly. The first issue is that my character gets stuck in the land animation at the start. The falling animation works normally, however. The second issue is that when I do land, I am stuck in the landing animation and I can't move my character.
I think there was a bug in this video. But maybe I screwed up somewhere. can anyone confirm. It wasn't working properly until I changed the if statement if(!isGrounded && !playerManager.isInteracting) into if(!isGrounded && playerManager.isInteracting) I could not get it to work other wise. the falling animation makes isInteracting = true so aslong as we are falling the first if statement will never be true because we are intercting when we are falling. but it is checking for us to not be interacting.
Well everything is working great but my land animation never plays.. It seens like the If condition is never meet (I checked the inspector and thats the case).
For now I've found that this version works perfectly: private void HandleFallingAndLanding() { RaycastHit hit; Vector3 rayCastOrigin = transform.position; rayCastOrigin.y = rayCastOrigin.y + rayCastHeightOffSet; if (!isGrounded) { if (!playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Falling", true); } inAirTimer = inAirTimer + Time.deltaTime; rb.AddForce(transform.forward * leapingVelocity); rb.AddForce(-Vector3.up * fallingVelocity * inAirTimer); } if (Physics.SphereCast(rayCastOrigin, 0.5f, Vector3.down, out hit, 0.5f, groundLayer)) { if(!isGrounded && playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Landing", true); } inAirTimer = 0; isGrounded = true; playerManager.isInteracting = false; } else { isGrounded = false; } } Credit to Jay Penter I've also used the landing animation where the player would bend alot and it introduced a problem where the collider would hit the platform and the animation would begin mid-air, then the player would stand normally on the platform, to fix this I went to the animation inspector and checked the "Root Transform Position" -> "Bake Into Pose" which fixed it for me.
when i run the game my character floats upward for a second, then drops very slowly and when he reaches the ground he does not do the land animation, he just hovers there unable to move
Where can I find these falling and landing animations. The drive link shared a few videos back doesn't have them. Are they behind a paywall or something? Being stuck 6 videos into a series does not instill confidence.
Awesome episode. A little fiddling around with the raycast length and offset made it all work nicely. One question though. If you would like to run up and down stairs, would you need two racasts at each foot to determine if the collided object is climbable or how would you do it? Right now you have to zig zag to be able to climp stairs.
There is some kind of bug where even if grounded is set to true, the player will start out in the 'falling idle' animation. If you manually set the bool to true in the inspector window (like he does in the video) it doesn't do that. Also in the physics sphereCast , isInteracting should be set to true.
My Player always plays the falling animation when going down the stairs, does somebody have a fix for this? allrdy tryed changing the values of the "rayCastMaxDistance", "rayCastSphereRadius" and the "rayCastHeighOffSet", but nothing seems to fix this. Also did all fixes from previous Videos. Maybe somebody can help me :)
you can try changing your rigidbody collsiion checking from discrete to continuos, if that doesn't work try messing with the values in the player locomotion script.
@@enzo.mp4247 reqork the code. for me also didnt work because i wrote "IsInteracting" instead of "isInteracting". just cant get my falling animation to work.
My fallling animation is finishing after I hit the ground before transitioning to the landing state, so I have this weird full to half second falling animation when I hit the ground before the landing animation plays. "isInteracting" and "isGrounded" are both setting the state immediately like they should, but the falling animation is still trying to finish.
click on the transition line in the animator window and make sure that the transition does not have "Has exit time" checked.. if it is checked, the transition will only occur once the animation loop has ended. So unchecking it, will let the transition happen as soon as the condition is true.
Sebastian. I ´have completed this script, but I have a problem. like if I even fall a little bit, it displays the falling and landing animation which I dont want, I only want it do to it when the player fell like 1 meter or more?
For anybody getting a weird error where the player does land and walks for a bit, but then suddenly enters the falling animation, Make sure that the capsule collider of the player covers their feet. Especially if using a different model. Tweak the collider so that the lowest point is inline with the bottom of the feet. This really messed me over for a while lol😂
Consider lowering the rayCastHeightOffSet to 0.2f instead of 0.5f as instructed in the video. Your collider capsule might be sized more fitting to the avatar than his(i had height of 1.8 instead of 1.7) where it is making it perform landing animation way far up from the ground.
I finnaly figured it out!!! I'll help you guys, i'll write everything that I know of that you can do to fix the falling bug. First of al is RootMotion in your animator controller, you need to disable it if your falling movement is really slow or your landing animation sets you off the ground. for the people that do want root motion, here is the newly edited part of the script to reanable RootMotion after the fall. Locomotion Script: if (!isGrounded) { if (!playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Falling", true); } animator.applyRootMotion = false; inAirTimer = inAirTimer + Time.deltaTime; playerRigidbody.AddForce(transform.forward * leapingVelocity); playerRigidbody.AddForce(Vector3.down * fallingVelocity * inAirTimer); } if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out hit, 1f, groundLayer)) { if (!isGrounded && playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Land", true); } if (animator.GetBool("doneLand") == true) { animator.applyRootMotion = true; } inAirTimer = 0; isGrounded = true; animator.SetBool("doneLand", false); } else { isGrounded = false; } and in the resetbool script: { animator.SetBool("isInteracting", isInteractingStatus); animator.SetBool("doneLand", true); } please note that you need to make a new bool variable Named doneLand in the animator parameters (you can also give it your own name). And for those who dont want to reanable RootMotion here is the edited part of the srcipt that still works but if you have a bad animation the you might get pushed of the ground. Locomotion Script: if (!isGrounded) { if (!playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Falling", true); } inAirTimer = inAirTimer + Time.deltaTime; playerRigidbody.AddForce(transform.forward * leapingVelocity); playerRigidbody.AddForce(Vector3.down * fallingVelocity * inAirTimer); } if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out hit, 1f, groundLayer)) { if (!isGrounded && playerManager.isInteracting) { animatorManager.PlayTargetAnimation("Land", true); } inAirTimer = 0; isGrounded = true; animator.SetBool("doneLand", false); } else { isGrounded = false; } one further note is to enable the Foot IK on your land animation in the animator controller. I hope this helps a few people
ive done every line of code, even did a little modifications from people in the comments and all work well, i cant seem to keep my character above the ground the model clips into the floor and stop at the center of it and i tried changing to raycast to -3 and -4 but it starts floating but when its at 0.2 its walkable but clipped into the ground. Anyone know how to fix?
Im getting this weird bug where my landing animation is overlaping my falling animation, causing it to not fall down but a bit up and then down, repeating itself, anyone knows how to fix this?
I found it was because of the autorig from mixamo, I imported the player model into blender and then I redid the rig and imported it into mixamo again and then used the animations and that fixed the issue in my case
Finally! You are awesome!!! When will you release the new episode? I Just need a rolling action and maybe a Jump, and i'll became a new patreon because your videos are gold!!!
Hey, thanks so much for making these tutorials! They're the best ones I've seen. I do have a small question. Even though (I think) I have the exact same code, by the end of the tutorial I wasn't able to get the game to recognize when the player is grounded or not. So my character just ends up moving very slowly, like in the start of the video. I was wondering if anyone found a solution to this or not? If I figure out the answer I'll make sure to document it here.
i wonder if anyone could help please. ive finished the vid but now my character doesnt move. His animation plays but he stays exactly where he is. The error I have is Animator.GotoState: State could not be found UnityEngine.Animator:CrossFade (string,single) - Invalid Layer Index '-1' UnityEngine.Animator:CrossFade (string,single) and its pointing to this part of the script: animator.CrossFade(targetAnimation,0.2f); Loving the tutorial but im a bit lost with this issue. Thank you :)
Sebastian, I followed everything in the tutorial but I keep getting a problem where the land Landing animation only plays when the Falling animation ends. I dont know whats going on.
Make a transition from the falling to the landing animation. Make the condition on it "IsGrounded". So it can only transition if the player is no longer in the air. Next uncheck "Has Exit Time" so the transition animation plays instantly. :^)
I think I've done all the code right but I'm having an issue. My character falls and lands correctly, but then just kind of bounces in place and I'm unable to move. The "isGrounded" bool blinks true/false and "isInteracting" bool in the animator stays on. Any help appreciated :)
Sebastian. Your 'Physics.SphereCast' is missing the 'maxDistance'. In the Unity's documentation, you can see that the 'layerMask' comes after the 'maxDistance'. You're feeding your 'groundLayer' (LayerMask) (that get's casted to 'int' by the 'LayerMask' operator). In the end your 'groundLayer' value for Unity IS the 'maxDistance'.
@@SebastianGraves I've double checked all available functions/methods in Unity's Physics class, there are no such overrides. The 'layerMask' always comes after the 'maxDistance'. Plus, see the Unity's documentation.
@@SebastianGraves Sorry. I was not aware of the C#4 feature for the 'Named and Optional Arguments' aka 'out of order' default variables. Looks dangerous... It seems that in your case the 'maxDistance' would simply get it's default 'Infinity' value. Thanks for your hard work. Really love your tutorials.
@@GGodis Huh, I just learned something new! Thanks for the bit of information. Glad you enjoy the content my friend :^)
@@SebastianGraves I did a bit more reaserch. There IS a problem as I've explained regarding the missing 'maxDistance'! Here is the proof: Your 'groundLayer' mask is using 'Default', as an 'int' it would be equal to '1'. Try and draw a sphere of the SphereCast collision 'hit.point'. Comment out your gravity code and try to move the player character in the Unity editor while in Play mode. You'll notice that the SphereCast would only detect collisions that are in the distance of '1'! Additionally, while in Play mode you can try and change your 'groundLayer' mask in the editor and you will notice how the SphereCast hit.point results will change when the player character is moved by mouse in the editor. So this is not even the case of C#'s 'Named and Optional Arguments', as in this case the 'maxDistance' would be 'Infinity' and your code logic would not work at all. ;) Hope this helps.
@@GGodis The layer identification being an int makes sense. I will re-pin the comment, for others to see! Thank you once again for the insight. I probably would not have noticed unless I revisited the series :^)
This is late but others down the line should find this useful I found personally this video needs a few fixes to work as shown in the vid: 1st- physics spherecast should be as follows: if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.Down, out hit, 0.5f, groundLayer)
2nd- on the grounded AND interacting if statement it should be as follows: if (!isGrounded && playerManager.isInteracting)
3rd- my problem was it would not exit the animation cycle no matter what so I never regained control of my player (ability to move again etc.) to fix this I added one extra line of code to stabilise: underneath inAirTimer=0; and isGrounded=true; add in this short line as follows: playerManager.isInteracting = false; (doesn’t need explaining I’m sure this line explains itself)
Hey bro it seems which you have mentioned is right, however there is one issue that is when starting its keeps on looping in falling animation, so it seems we have to add this line on :
Void Awake()
{
isGounded = true;
}
so that the falling animation doesn't loops the player falling when it start.
Jay, thank you for this. It really helped
@@edawkingyoutube4004 Which script would this be added to?
That last line is just what I was looking for.😁
Thank youuuuu!🥹
You're a god level teacher and a brilliant programmer Sebastian, thank you so much!!
Guys in order to make it instant to switch to landing animation, on the transition from falling to landing uncheck the "Has exit Time", and add the condition "isInteracting" to true
First of all, great tutorial. Thanks for your amazing work.
I had a problem with the falling animation and i am seeing many people having a similar problem in the comments. In my case the solution was simply modifying the transition from falling to landing. I unchecked the "has exit time" on this transition, and added "isInteracting" bool as a condition for this transition and set it to "true". This solved the problem.
However i must give my warning, i am not an expert in unity, so this is just something that worked for me. It might work for you, but there is a possibility that this is not actually a good solution. So take care if you want to apply it.
"Very simple and very straightforward!" Thanks a lot for this series.
I like how you arent afraid to use headers and stuff to organize your code, so many other tutorials skip over that so its never learned.
if your land animation play in the air even if player is landed
then here's the fix --> on your Animation go to "root Transform position Y" and change it from Original To Feet
thanks for the fix man, and what he means is to edit the animation file's import settings not in the animator
@@chez-wren How do i do that?
thanks bro
to anyone who desires a smoother transition between landing and the locomotion, play with the speed of the landing animation and instead of the return function activating when an input is active, have it activate when the player isnt grounded. I also added my animations to the base layer and connected them to the locomotion, although im not sure how much this impacted the overall smoothing of the animation.
To all the people who get stuck in land animation, just check in your base Layer (Animator), and if you have a land animation just delete it.
You just need one animation on the override section. Because if you got the landing animation in double it will get stuck playing it.
Hope it will help.
for anyone whose character is stuck :
change your raycastheightoffset value to -3 or -4 depending on your character model (if you are not using his model) , the problem for me was that the raycast position was at the center of my character and not at his feet so it was not able to detect the ground at all.
Put is grounded will be fals if your plate is thin
Honestly your videos are better than Unity's and other paid courses. Please keep them coming! Would love to see more movement based content like jumping and parkour stuff.
I unchecked RootMotion in the animator and it solved like 90% of my problems lol
i love these tutorials your better then Brackeys and you explain things so well thank you so much i am new to unity and working on my first real try at a game and these have been tremendously helping me thank you and try to get the next one out fast im hoping its either in jumping or stamina thx for all the help :)
So glad you made this video when you did! I've been trying to figure out the whole character model slowly falling thing for a while now!!
How did you fix that?
I'm learning more from your series than the year and a half i spent learning unity, thanks for doing these!
Thank you for making this basic version. Really helpful for a newbie like me
I'm going to be backing the patreon as soon as I get paid at the end of the month
Great episode Sebastian!!! Sorry to hear about your hard drive issues. Hoping the next episode comes out soon.
Ran into a couple of problems, I can fall fast now but I've had to push those numbers to the extreme, and I'm still not doing the falling animation just jittering a lot when I lead from the leadge, but when I start my player above the ground it works
and i cant falling XD
Note for anyone having trouble with the landing or falling try these stuff
1.make the capsule collider 2 instead of 1.8 if using low poly man
2. Use play instead of crossfade
3.on the land animation go to root transform position y and making it from original to feet.
😊
how would i implement play in place of cross fade?
@@traynorth83have you found this out yet
For anyone struggling here, I found it best to add a visualizer of the spherecast by using my player's capsule collider as the source of spherecast radius.
To do this add two globals at the beginning:
public Gameobject sphereCastVisual; // You'll need to create Sphere gameObject in scene and pass it in
CapsuleCollider characterCollider; // Character's collider capsule
(get the character collider within awake similar to how we get rigidBody `characterCollider = GetComponent();`)
Then at the start of your HandleFalling():
RaycastHit hit;
Vector3 rayCastOrigin = transform.position;
rayCastOrigin.y += rayCastOffset + characterCollider.radius; // offset with the radius of your capsuleCollider to bring up proper distance
// Visualize Spherecast Starting Position
sphereCastVisual.transform.localScale = Vector3.one * 2 * characterCollider.radius; // changing scale to the diameter of sphere
sphereCastVisual.transform.position = rayCastOrigin;
My initial thinking of the SphereCast was that it would create a sphere and check if anything is hit within that sphere, but that is not the case. It actually creates a sphere and shoots it along the provided vector for a provided distance and returns true and the hit object if the sphere hits anything along that vector.
Lastly, I changed SphereCast to this:
Physics.SphereCast(rayCastOrigin, characterCollider.radius, -transform.up, out hit, maxDistance, groundLayer)
So in summary, this creates a sphere of radius equivalent to the character capsule collider, centered at the feet of the character (plus the radius of the sphere as set above + given offset), shoots a straight line down (relative to player transform) of distance maxDistance, and outputs the hit object details if anything is hit within the groundLayer.
** Note I used -transform.up rather than Vector3.down to allow for character rotation in future, as I plan to have my character run around planets with local gravity **
If you are sometimes falling through the floor, make sure on your rigidbody that colision detection is set to continuous!
Absolutely fantastic series so far. The clear explanations of what you are doing and why is very good. Can not wait for what is coming in the next couple of weeks. Going to start your Dark Souls in Unity series at some point next week.
What kind of movement will you be covering next? I would personally love to see the following:
Jumping
Double Jumping
Vaulting
Ledge Climbing/Mantling
Crouching/Crouch Walking
Prone
Obviously not all of these but it would be cool to see how you approach one of these mechanics using the New Input System
a new underrated champion has risen!
finally 3 weeks wait has come to an end🔥🙌
As always, a wonderful and clearly spoken tutorial. Looking forward to #7
For All the people who cant find animations go download them of mixamo there is a lot of free animations to choose from.
congratulations for 8k!
Thank you my friend :^)
Ok, after a few hours of trying to figure it out... My main issue was the animation type of my falling and landing animations. You must remember to put them in humanoid mode in the rig tab otherwise they will not play correctly or even not at all
I had some problems with falling and landing animations not playing at all; could still move while falling and finally my model would fall under ground. Here is what I did:
- tried every possible solution in the comment section, there is only one suggested fix that worked: if (Physics.SphereCast(rayCastOrigin, 0.2f, -Vector3.up, out hit, maxDistance, groundLayer))
then adding public float maxDistance = 1;
- made sure that all spellings are correct (for the bool names)
- You have to make a transition from falling to landing but DO NOT assign any conditions AND keep the "Has exit time" boxes checked!
- Your falling animation should be looping and landing should NOT
- Make sure that your Animator does not have Apply Root Motion box checked
- Instead of a Box Collider I used mash collider and my model is no longer falling under ground
These steps helpmed me to resolve the issues
where did you originally use the box collider? also thanks so much for this
I used mash collider on the ground. Also, if you did everything properly but your character is gliding even when you land (run/walk then jump with W key press) you have to add friction to the ground ( friction 1 works)@@jred7333
ANYONE WHO IS USING MIXAMO:
- Make sure to make it a humanoid; Animation->Rig->Animation Type->Humanoid (I don't know if everyone knew this or it was just me)
Make shooting system tutorials too and i am in love with this series ❤️
I had to rewrite this code 3 times before I got it working haha, I'm terrible at scripting so maybe that is why.... What I'm trying to say is don't get discouraged if you don't get it the first time and also don't be afraid of starting over.
Great tutorial as always!
Im not sure why, but I needed to double my transform y value to get the ground detection working, have been following the series to t otherwise, has this been an issue for anyone else?
gotta love when i make 1 simple typo and get lost for hours on it.
What is the benefit of using "-Vector3.up" vs. "Vector3.down" when applying force at 9:35?
same thing
he is bad idk where he gets his scripts
@@wanchester6626 He makes his own scripts bro, unlike you he doesnt just copy everything😂
They act the exact same, my best guess to why he used "-Vector3.up" is because in a lot *most* game engines, they won't have a Vector3.down, because storing that in the Vector3 class as a static variable or similar uses more storage and is useless, so if you want a game engine focused on being lightweight then you would only have Vector3.up, Vector3.right, and Vector3.forward, and even that some engines dont have, instead forcing you to write your own like "new Vector3(0, 1, 0)" which is equivalent to Vector3.up. Unity brands its self on being accessible to anyone, so forcing people to use weird syntax like "-Vector3.up" can be off-putting, so thats why unity decided to include it in their engine, but this video is more of focused on teaching code and stuff rather than "What is the simplest or most efficient way of writing this code". its the same reason why he basically never uses the +=, -=, *=, or /= operators, because some languages like Python, don't have those.
The player ground check only works on the ground, not on any other object, the layers are all the same.
Hello,
I notice this is similar to the Dark Souls tutorial. What separates this from that? Is it a versatility thing or is it more of an update with a generic theme?
I like this so far; the falling trigger is a little sensitive so the player falls near walls and when running downhill on a rough slope. Any tips to check for those issues? Thanks.
did you find a solution?
@@asddsadsad-b8b I did, but it's been so long since I messed with this one that I don't remember exactly what it was. It wasn't perfect though. I believe it had something to do with the if(inAirTimer=0) line, which in my code is if(inAirTimeer>0.1f). Other than that, it may be something to do with the raycast coming from the collider. Either shorten or lengthen the hit distance maybe? Sorry, but it's been awhile on this one. I ended up writing a controller from scratch so I could be sure I fully understood how everything was put together and that only fit what I needed.
@@DESTOVIAC ok, thanks!
FALLING SLOWLY
Add the "maxDistance" parameter to the SphereCast
Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out RaycastHit hit, 0.2f, groundLayer)
STUCK IN FALLING ANIMATION
Make sure the player IS interacting before landing. The falling animation sets isInteracting to true
if (!isGrounded && playerManager.isInteracting) {
Thanks!!!!
@Namado check your rayCastOffsetHeight, change it to 0 or something that works for you
To get same results as in the video, the 'maxDistance' should be not '0.2f', but '1f'. This is because Sebastian was using the 'groundLayer' mask set only to 'Default'. (When casting 'groundLayer' to 'int' it would result in '1'). Unity's 'SphereCast' took Sebastian's 'groundLayer' for the 'maxDistance'. The real 'layerMask' remained 'DefaultRaycastLayers'.
@@GGodis i was literally going insane trying to understand this. cheers :)
Thank you! I couldn't figure it out.
You can also remove RayCastHit hit and replace it with _
if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out _, 0.5f, groundLayer))
Guys, I finally found it out. If you get stuck after you fall give your floor a rigidbody, take off use gravity, and give all freeze positions a tick. It seemed to do it for me
Also collision detection Continuous
Can you induce player movement as player go up and down the slope? Thank you for this video
Hello guys I need help my falling and landing are not working its like they keep on looping and it never jumps to empty and when it does jump to empty it is for a very short time
Did you get a fix for this? Mine keeps randomly changing inAirTimer and playing land and fall but it just gets stuck on the first frames and switches between them.
Do you have a link containing the animations of falling and landing?
My character is floating and repeating the falling and landing animations again and again and also my character is going up instead of landing. Please help me...
in the inspector u need to change the RayCastHeightOffSet. try 0.3 or 0.5, maybe it work
Greate series so far, this one is a little rough though.
I am having a strange issue with my project for the falling and landing of a 3rd person controller.
There doesnt seem to be any immediate issues with my code
No errors or warnings
however, my character still floats in the air, the isGrounded bool never gets unchecked
The animations transitions get stuck and frozen if I force the bool to be false.
and Im given no warnings or errors as to why
So i have no idea where to start
an extra bit of detail i just noticed
upon starting the scene, the ground variable is active and set to true
If I walk off a ledge, it stays active and I float
When I force-ably de-activate isGrounded during play
this is what happens within an instant and a split seconf
First : Players gravity kicks in and starts to fall normally
Second : Ground variable goes from false to true again instantly, even before hitting the ground
Third : Player animations play until either they hit the ground or they finish playing.
Forth : The player animations then stay stuck frozen in the end state of the animation
still no errors from unity or from Visual studio
Im not sure why when im grounded and the animation is playing even though isInteracting is TRUE, the handlemovement/rotation script is working. Is return function not working?
Semi-new subscriber here! Love this series, thanks for making it :). I can’t wait for the next one.
Do you have a set schedule for new vids in this series (I.e. once every 2-3 weeks) or is it just whenever you can get them out?
When ever I can currently! :^)
So when I hit play my character immediately starts floating up, then comes down after 30 ft or so and bobs up and down off the ground. in the inspector it looks like its cycling between being grounded and not grounded but i cant find an issue with the code.
Stuff is happening to me as well. I don't know how adding a downward force can do this, but as I move about, my speed slowing decreases exponentially until I can only turn.
@Sebastian Graves PLEASE PROVIDE A SOLUTION FOR THIS D:
When I finished and tested the final thing out, but I ran into two small problems, one (which is not a big deal) the falling and landing animation plays as soon as I start the game, and the other issue is when I fall and then land, the landing animation is slightly delayed and is played a second time after as well
I had the same problem with my landing animation being called twice. I solved by unckecking "Loop time" in my landing animation
Same here, I noticed the raycast height offset has a factor also. Have you solved this one?
For me checking the box
Root Transform Position (Y)
Bake Into Pose
helped
Did anyone ever find a solution to this ?
Is there any way at all to allow movement during the falling/jumping?
I've tried everything to get freedom of movement while mid-air, but nothing works. I even tried creating separate HandleJumpMovement and HandleJumpRotation methods to call instead of altering the normal movement, but that didn't work either. I really just want to be able to move freely without any frozen rotation or movement, on top of no longer freezing when landing, but I haven't found a way to do so at all and so the movement doesn't feel as reactive or fluent as it could be.
Recreate the HandleMovement() in the HandleFallingAndLanding() but change playerRigidbody.velocity = movementVelocity; to playerRigidbody.velocity = new Vector3(movementVelocity.x, playerRigidbody.velocity.y, movementVelocity.z);
so do you mean I should paste the handlemovement code into handlefallingandlanding() is it inside if(!isGrounded)?
@@jred7333
my ResetBool isnt interacting with my isInteracting Bool in the animator how do i go about fixing that.
I got an error 01 ( Invalid Layer Index '-1'
UnityEngine.Animator:CrossFade (string,single) ) 02 ( Animator.GotoState: State could not be found
UnityEngine.Animator:CrossFade (string,single) ) how can i solve this ?
Me Too
I fixed that I had used the wrong name for my falling animation I used "Falling" but mine is just called "Fall"
@@WaymondDH thankyou sir
@@WaymondDH Holy crap thanks
when im falling i cant move my player it stand in place and when landed i can walk but why?
Using this line --> if(Physics.CheckSphere(rayCastOrigin, 0.2f, groundLayer))
will give better results than this --> if(Physics.SphereCast(rayCastOrigin, 0.2f, groundLayer, out hit))
Can you explain why?
@@epicdoggames9667 Ya. So CheckSphere uses lesser processor usage than SphereCast which can improve the game performance
@@anshgulavani4854 thanks for the information
Cool, but it's very likely that you'll need some additional information from the 'hit' class in the future anyway.
I am having a few issues despite doing the code correctly.
The first issue is that my character gets stuck in the land animation at the start. The falling animation works normally, however.
The second issue is that when I do land, I am stuck in the landing animation and I can't move my character.
Mine is doing same if you find how to fix this please let me know
the one of the series was kind of confusing for me, but this is N E A T
I think there was a bug in this video. But maybe I screwed up somewhere.
can anyone confirm. It wasn't working properly until I changed the if statement
if(!isGrounded && !playerManager.isInteracting)
into
if(!isGrounded && playerManager.isInteracting)
I could not get it to work other wise.
the falling animation makes isInteracting = true
so aslong as we are falling the first if statement will never be true because we are intercting when we are falling. but it is checking for us to not be interacting.
Same here. Any idea why this works?
@@AaronAsherRandall i got the same issue, just remove the part "&& player.isInteracting" works for me
if (Physisc.SphereCast...) {
if (!isGrounded) {
Well everything is working great but my land animation never plays.. It seens like the If condition is never meet (I checked the inspector and thats the case).
For now I've found that this version works perfectly:
private void HandleFallingAndLanding()
{
RaycastHit hit;
Vector3 rayCastOrigin = transform.position;
rayCastOrigin.y = rayCastOrigin.y + rayCastHeightOffSet;
if (!isGrounded)
{
if (!playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Falling", true);
}
inAirTimer = inAirTimer + Time.deltaTime;
rb.AddForce(transform.forward * leapingVelocity);
rb.AddForce(-Vector3.up * fallingVelocity * inAirTimer);
}
if (Physics.SphereCast(rayCastOrigin, 0.5f, Vector3.down, out hit, 0.5f, groundLayer))
{
if(!isGrounded && playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Landing", true);
}
inAirTimer = 0;
isGrounded = true;
playerManager.isInteracting = false;
}
else
{
isGrounded = false;
}
}
Credit to Jay Penter
I've also used the landing animation where the player would bend alot and it introduced a problem where the collider would hit the platform and the animation would begin mid-air, then the player would stand normally on the platform, to fix this I went to the animation inspector and checked the "Root Transform Position" -> "Bake Into Pose" which fixed it for me.
Thankssss
when i run the game my character floats upward for a second, then drops very slowly and when he reaches the ground he does not do the land animation, he just hovers there
unable to move
Where can I find these falling and landing animations. The drive link shared a few videos back doesn't have them. Are they behind a paywall or something?
Being stuck 6 videos into a series does not instill confidence.
Basic Motions FREE by Kevin Iglesias
Awesome episode. A little fiddling around with the raycast length and offset made it all work nicely. One question though. If you would like to run up and down stairs, would you need two racasts at each foot to determine if the collided object is climbable or how would you do it? Right now you have to zig zag to be able to climp stairs.
There is some kind of bug where even if grounded is set to true, the player will start out in the 'falling idle' animation. If you manually set the bool to true in the inspector window (like he does in the video) it doesn't do that. Also in the physics sphereCast , isInteracting should be set to true.
you need to change the if(!isGrounded && !playerManager.isInteracting) to if(!isGrounded && playerManager.isInteracting)
@@mixedtrigenito actually i decided that i don't care about this anymore. fuck this.
My Player always plays the falling animation when going down the stairs, does somebody have a fix for this? allrdy tryed changing the values of the "rayCastMaxDistance", "rayCastSphereRadius" and the "rayCastHeighOffSet", but nothing seems to fix this. Also did all fixes from previous Videos. Maybe somebody can help me :)
What's the name of the falling animations you got on the unity marketplace?
Basic Motions FREE by Kevin Iglesias
i have appeased the youtube algorithm gods
My character doesn't move vertically when I jump, the animation works, but it doesn't go up, anyone can help?
I got Probleme, when my start value if is grounded is true it do not get into the falling animation
Im having an issue where the feet clip through the plane that im supposed to land on? Im not sure where this issue is coming from
you can try changing your rigidbody collsiion checking from discrete to continuos, if that doesn't work try messing with the values in the player locomotion script.
where is the falling animation, now can we find it, its not in google drive
im using two animations from mixamo, falling idle and falling to landing, hope this helps
it isnt working :( i followed the script and checked everything over no errors it just wont work Help plz
same problem mate did find a solution please, Im totally stuck!
@@enzo.mp4247 reqork the code. for me also didnt work because i wrote "IsInteracting" instead of "isInteracting". just cant get my falling animation to work.
My fallling animation is finishing after I hit the ground before transitioning to the landing state, so I have this weird full to half second falling animation when I hit the ground before the landing animation plays. "isInteracting" and "isGrounded" are both setting the state immediately like they should, but the falling animation is still trying to finish.
click on the transition line in the animator window and make sure that the transition does not have "Has exit time" checked.. if it is checked, the transition will only occur once the animation loop has ended. So unchecking it, will let the transition happen as soon as the condition is true.
or just remove the transition like he said
why my player falls really slowly? didn't change rigidbody setting and everything's the same as in video
Sebastian. I ´have completed this script, but I have a problem. like if I even fall a little bit, it displays the falling and landing animation which I dont want, I only want it do to it when the player fell like 1 meter or more?
you can just add an if statement something like, "if (inAirTime > x)"
Thanks for the video brother...😀👍🏻
what if I don't have flat land
how do I prevent my character from playing the animation every time it walks down a slope?
mine works fine without a landing animation
you can call isgrounded in the awake method. so the animation doesnt play at the beginning.
For anybody getting a weird error where the player does land and walks for a bit, but then suddenly enters the falling animation, Make sure that the capsule collider of the player covers their feet. Especially if using a different model. Tweak the collider so that the lowest point is inline with the bottom of the feet.
This really messed me over for a while lol😂
the detection isnt working right my player moves to the landing animation without even touching the ground
Add the condition isInteracting = false to the transition from "Falling" to "Land".
Consider lowering the rayCastHeightOffSet to 0.2f instead of 0.5f as instructed in the video. Your collider capsule might be sized more fitting to the avatar than his(i had height of 1.8 instead of 1.7) where it is making it perform landing animation way far up from the ground.
Can you send me a Link to the Falling and Landing Animations? I cant find something like this in the asset store
Basic Motions FREE by Kevin Iglesias
I finnaly figured it out!!!
I'll help you guys, i'll write everything that I know of that you can do to fix the falling bug.
First of al is RootMotion in your animator controller, you need to disable it if your falling movement is really slow or your landing animation sets you off the ground. for the people that do want root motion, here is the newly edited part of the script to reanable RootMotion after the fall.
Locomotion Script:
if (!isGrounded)
{
if (!playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Falling", true);
}
animator.applyRootMotion = false;
inAirTimer = inAirTimer + Time.deltaTime;
playerRigidbody.AddForce(transform.forward * leapingVelocity);
playerRigidbody.AddForce(Vector3.down * fallingVelocity * inAirTimer);
}
if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out hit, 1f, groundLayer))
{
if (!isGrounded && playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Land", true);
}
if (animator.GetBool("doneLand") == true)
{
animator.applyRootMotion = true;
}
inAirTimer = 0;
isGrounded = true;
animator.SetBool("doneLand", false);
}
else
{
isGrounded = false;
}
and in the resetbool script:
{
animator.SetBool("isInteracting", isInteractingStatus);
animator.SetBool("doneLand", true);
}
please note that you need to make a new bool variable Named doneLand in the animator parameters (you can also give it your own name).
And for those who dont want to reanable RootMotion here is the edited part of the srcipt that still works but if you have a bad animation the you might get pushed of the ground.
Locomotion Script:
if (!isGrounded)
{
if (!playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Falling", true);
}
inAirTimer = inAirTimer + Time.deltaTime;
playerRigidbody.AddForce(transform.forward * leapingVelocity);
playerRigidbody.AddForce(Vector3.down * fallingVelocity * inAirTimer);
}
if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out hit, 1f, groundLayer))
{
if (!isGrounded && playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("Land", true);
}
inAirTimer = 0;
isGrounded = true;
animator.SetBool("doneLand", false);
}
else
{
isGrounded = false;
}
one further note is to enable the Foot IK on your land animation in the animator controller.
I hope this helps a few people
This fixed a lot of problems, thank you!
Thank you!
ive done every line of code, even did a little modifications from people in the comments and all work well, i cant seem to keep my character above the ground the model clips into the floor and stop at the center of it and i tried changing to raycast to -3 and -4 but it starts floating but when its at 0.2 its walkable but clipped into the ground. Anyone know how to fix?
Im getting this weird bug where my landing animation is overlaping my falling animation, causing it to not fall down but a bit up and then down, repeating itself, anyone knows how to fix this?
I am facing the same issue
i have the same problem :(
I found it was because of the autorig from mixamo, I imported the player model into blender and then I redid the rig and imported it into mixamo again and then used the animations and that fixed the issue in my case
Everything works but I don't understand why the falling animation doesn't open
My landing animation goes through floor how do I fix that? Do I need a new animation?
Fixed it but now it activates too soon and is done before I hit the ground
hi , i got problem when walking to the slant surface its sliding
Would you believe me if I said you are my hero?
0:18 no that's what I want, IRL
Finally! You are awesome!!! When will you release the new episode? I Just need a rolling action and maybe a Jump, and i'll became a new patreon because your videos are gold!!!
This weekend! If my PC is back in working order :^)
Hey, thanks so much for making these tutorials! They're the best ones I've seen. I do have a small question. Even though (I think) I have the exact same code, by the end of the tutorial I wasn't able to get the game to recognize when the player is grounded or not. So my character just ends up moving very slowly, like in the start of the video. I was wondering if anyone found a solution to this or not? If I figure out the answer I'll make sure to document it here.
I am also still able to make the character walk while in air, but I'm not sure how to fix it.
Any idea why my character falls like molasses even when I have the falling velocity up to 350?
did you ever find a fix?
@ got too frustrating. Switched to UE5
isnt the raycast detecting the player capsule collider before the environment colliders ?
I know this is a late response, but thats why we have the "groundLayer" variable, because the raycast will only detect layers in that layermask
Hey man can you make a video about strafe walking animation and its code
Could you make first person char controller climb tutorial ?
can you do climbing logic as well?
i wonder if anyone could help please. ive finished the vid but now my character doesnt move. His animation plays but he stays exactly where he is. The error I have is
Animator.GotoState: State could not be found
UnityEngine.Animator:CrossFade (string,single) -
Invalid Layer Index '-1'
UnityEngine.Animator:CrossFade (string,single) and its pointing to this part of the script: animator.CrossFade(targetAnimation,0.2f); Loving the tutorial but im a bit lost with this issue. Thank you :)
your animation in the project is probably named different than the one you're calling
Sebastian, I followed everything in the tutorial but I keep getting a problem where the land Landing animation only plays when the Falling animation ends. I dont know whats going on.
Make a transition from the falling to the landing animation. Make the condition on it "IsGrounded". So it can only transition if the player is no longer in the air.
Next uncheck "Has Exit Time" so the transition animation plays instantly. :^)
I think I've done all the code right but I'm having an issue. My character falls and lands correctly, but then just kind of bounces in place and I'm unable to move. The "isGrounded" bool blinks true/false and "isInteracting" bool in the animator stays on. Any help appreciated :)
same problem bro
isInteracting doesn't get checked ever, anyone know what the problem might be?