3RD PERSON CONTROLLER in Unity - CAMERA

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024
  • In this video (Episode 4) we implement movement animations for our player via animator values, that will be changed based on our input!
    ► PLAYER MODEL & ANIMATIONS
    drive.google.c...
    ► JOIN OUR DISCORD
    / discord
    ► SUPPORT ME ON PATREON!
    / sebastiangraves
    ► ASSET STORE PAGE (Animations & Models)
    assetstore.uni...
    ► FOLLOW ME IN INSTAGRAM!
    / tragicallycanadian
    ► EPISODE 5
    • 3RD PERSON CONTROLLER ...

Комментарии • 325

  • @kotcstudios
    @kotcstudios 27 дней назад +1

    Ive spent the last 2 weeks messing around with 3rd person controllers from the asset store, tutorials and anything else I could find, but this is definitely the best I have found. This gives the exact player movement and camera rotation/collision I was looking for.
    You are one bad ass dude!
    Thank you!

  • @phee3D
    @phee3D 3 года назад +44

    For fixing the jittery camera, simply use Lerp to interpolate camera from its last position smoothly. The jitter happens because of the micro errors our hand naturally makes when moving things like a mouse. Here's my code at the top of the CameraManger script's RotateCamera method:
    lookAngle = Mathf.Lerp(lookAngle, lookAngle + (_inputManager.mouseX * _cameraLookSpeed), _camLookSmoothTime * Time.deltaTime);
    pivotAngle = Mathf.Lerp(pivotAngle, pivotAngle - (_inputManager.mouseY * _cameraPivotSpeed), _camLookSmoothTime * Time.deltaTime);
    and here's the value I found to be good starting point for the variables:
    _cameraLookSpeed = 15
    _cameraPivotSpeed = 15
    _camLookSmoothTime = 1
    you can play around with these values to get even smoother results

    • @PranjayMittal
      @PranjayMittal 6 дней назад

      jitter doesnt happen cause of the micro errors lol even if your move direction values are exactly 0 and 1 it still happens. probably because of the motion of the animations. can also be fixed by putting the player model and animation components under a empty with your scripts

    • @phee3D
      @phee3D 6 дней назад

      @@PranjayMittal it does happen because of micro errors but probably not the jitter you are thinking of. I don't really stand behind using Lerp for smoothing the camera anymore especially if your game needs any form of accuracy. Players are already used to the slight jitter that happens because of your mouse. But anyways, to determine if we're talking about the same jitter, temporarily bind your camera controls to a keyboard key like A and D. If the jitter still happens, we're not talking about the same thing.

    • @PranjayMittal
      @PranjayMittal 6 дней назад

      @@phee3D yeah i did that, that's why i said it happens even when its accurate. So yes i think we are probably taking about different things lol.

  • @garybuchert7005
    @garybuchert7005 2 года назад +12

    Thank you Sebastian for another great tutorial!
    For anyone that might have an issue with the camera clipping into the player model when running towards the camera with S, change your camera follow speed. I found that 0.04 worked best for me.
    EDIT: Might be worth noting my main camera is -4 on the z axis.

    • @carlosmarques6067
      @carlosmarques6067 7 месяцев назад +1

      thanks bro

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @Zack-pu8xi
    @Zack-pu8xi 3 года назад +15

    There's a reason why this video has zero Dislikes, Good work Boss Man thanks for the tutorial

  • @mathiasschoen4006
    @mathiasschoen4006 3 года назад +29

    Just wanted to let you know how much fun and meaningful all your tutorials have been so far, went from knowing only very basic C# concepts to understanding vectors, classes, quaternions, etc. just from watching your videos here and there. Thanks a ton and keep up the good work!!

    • @SebastianGraves
      @SebastianGraves  3 года назад +8

      This kind of feedback is really fantastic to read! I am very glad you took something away from the series my friend :^)

  • @TheGamerElectric
    @TheGamerElectric 2 года назад +4

    Was getting frustrated with the collision detection on the camera and literally was so confused. Rewatched you scripting it for at least 20 minutes was about to get off and take a break then realized i had misspelled default and position with defualt and postion god i almost lost my mind. I also had to rewrite the input actions because the Camera input caused the entire game to get a compiling error. Rewiring the input took away the camera problem but then the vectors on WASD were not being registered, a quick google searched show that all i had to do was restart unity and to myself i thought "ah yes unity at its finest." This entire journey just for character movement and camera control has been absolute blast despite the panic attacks, anxiety, lack of concentration, My daughter asking me what each word does and why im adding stars and plus sign if they're no numbers just words. Seriously enjoying this so far, i've come farther than any other tutorial has gotten me just with this one series. Good work man, you'll do good work some day or mindless work.

    • @SebastianGraves
      @SebastianGraves  2 года назад +2

      Hahahaah. Ahh yes, the rollercoaster that is learning Unity.

  • @sounghungi
    @sounghungi 2 года назад +9

    I don't know if anyone answered why you need Interpolate on but the reason that you have to turn it on is because the physics is on a fixed delta time versus LateUpdate or Update which have a unlocked delta time. So when the camera follows the player, it is seeing the rigidbody twice or three times depending on the FPS you are running at. When you enable interpolate, the rigidbody will fill in the in-between frames.

  • @humanoidgamedev3159
    @humanoidgamedev3159 2 года назад +5

    It's amazing to see you reply to comments even a year after the video, trust me you'll one day become the most popular unity programmer.

  • @TheOnlyK1ng
    @TheOnlyK1ng Год назад +1

    This is the best series I have ever watched on making a 3rd person controller. After hours of watching many other tutorials, your videos are the most helpful! Thank you very much for making such high quality videos!

  • @epicdoggames9667
    @epicdoggames9667 3 года назад +6

    Breathlessly waiting for the next episode. Have fingers crossed it will be soon.

  • @JLee118
    @JLee118 3 года назад +5

    I didn’t realize you could use the slash notes that way, thanks!

  • @noicenoise8718
    @noicenoise8718 3 года назад +4

    It's still advantageous to know the basics setting up a simple camera like this one than diving cinemachine on the go

  • @luminasdiary
    @luminasdiary 3 года назад +5

    This is a really clean and tidy implementation of 3rd person controls, great if we need to make our own tweaks. Although this already behaves exactly as I wanted it, thanks for your great work dude.

  • @ImFlixey
    @ImFlixey 2 года назад +51

    For anyone having an issue where the camera jumps further away from the wall whenever you collide with it:
    Change:
    targetPosition = targetPosition - (distance - cameraCollisionOffset);
    To:
    targetPosition = -(distance - cameraCollisionOffset);

    • @slavkodem70
      @slavkodem70 Год назад +2

      I have changed it but still no effect, camera clips through the wall on collision and wont work properly

    • @meetpatel6632
      @meetpatel6632 Год назад +1

      @@slavkodem70 Use targetPosition = targetPosition + (distance - cameraCollisionOffset);

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

    • @MasterKibo
      @MasterKibo 3 месяца назад

      Thank you

  • @roberthenderson9175
    @roberthenderson9175 3 года назад +1

    Awesome tutorial! It actually addressed the new input system so people can understand how to USE IT!!!

  • @transitia1869
    @transitia1869 2 года назад +2

    If Brackeys didt leave you guys should DEFINTLY collab this is Amazing!

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

    • @transitia1869
      @transitia1869 4 месяца назад

      @@JoskeVR I’m sorry I deleted it already it’s to long ago

  • @anshgulavani4854
    @anshgulavani4854 3 года назад +10

    Your series is great!. Btw Interpolation just sync's the rigidbody with the camera depth and makes it look smooth. I knew we would have a problem like this so i had set it to interpolate from start.

    • @matthewfoley1875
      @matthewfoley1875 3 года назад +2

      To add to this: It interpolates between the original position of the rigidbody and the new position at the end of the stutter, smoothing the transition. It operates in a similar fashion as Mathf.lerp()

  • @ColdOneK
    @ColdOneK 2 года назад +4

    Floats/Ints/etc have min & max values, so it's a good idea to limit them, so as to not reach those values. Odd stuff could happen ;D
    if (lookAngle >= 360)
    lookAngle = 0;
    if (lookAngle

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @SpoonTaco
    @SpoonTaco 3 года назад +1

    :') u know ur a great teacher when someone just wants to copy u but actually learns

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

    • @SpoonTaco
      @SpoonTaco 4 месяца назад

      @@JoskeVR he did make a script from what i remember, it was 3 years ago but i remember downloading it or copying it from his description. He gives it to u and teaches u

  • @Stryftek
    @Stryftek Год назад +3

    Camera Collision "FIX" 30:42
    This is what I missed, hopefully it'll help someone else. When he changes the targetPosition part of the script to be a =-, well that already references itself so you need to move the other targetPosition.
    So it goes from :
    targetPosition = targetPosition - (distance - cameraCollisionOffSet);
    and it needs to be THIS :
    targetPosition =- (distance - cameraCollisionOffSet);
    What happened was mine was :
    targetPosition =- targetPosition - (distance - cameraCollisionOffSet);
    Yeah, silly mistake. But hopefully this helps someone else!

    • @MrGarfield83
      @MrGarfield83 Год назад +1

      And if you don't want your camera to start below the collision surface, replace the line :
      cameraVectorPosition.z = Mathf.Lerp(camera.transform.localPosition.z, targetPosition, .2f);
      with the following lines of code:
      if (Mathf.Abs(camera.transform.localPosition.z) > Mathf.Abs(targetPosition))
      cameraVectorPosition.z = targetPosition;
      else
      targetPosition.z = Mathf.Lerp(camera.transform.localPosition.z, targetPosition, .2f);

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

    • @jvnm2890
      @jvnm2890 3 месяца назад

      @@JoskeVR If you tried copy and pasting mrgarfields code it won't work because localPosition.z indicates its taking from a Vector3 but the float targetPosition isnt a Vector3, i'd just try to figure out a solution with chatGPT stating your problem and then trying it's solutions while applying some common sense and your own context.

  • @engincansisman6927
    @engincansisman6927 2 месяца назад

    If your camera automatically starts at the character's feet or somewhere you don't want it to. Set the transform of the camera pivot gameobject without the main camera parent, and then assign the main camera as the parent again.
    By the way Thank you for this tutorials Sebastian :)

  • @duelator2813
    @duelator2813 2 года назад

    Fantastic tutorial, I am absolutely loving this series so far. you are a very underrated youtuber and tutor. Thanks a lot man

  • @Ahelwany
    @Ahelwany 2 года назад +1

    Much thanks to your great tutorials, Sebastian!
    they have greatly expanded my game development knowledge, and I am always looking forward to watch more of your videos :)

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @notwicio9230
    @notwicio9230 2 года назад +2

    just wanted to say thank you, i am making squid game in unity and your tutorials help me out a lot :)

    • @SebastianGraves
      @SebastianGraves  2 года назад

      Sounds like an awesome concept! Best of luck. :^)

    • @coronalife8564
      @coronalife8564 2 года назад

      Haha me too, green light red light?

  • @dereksullivan1501
    @dereksullivan1501 Год назад +1

    Thanks for making this understandable. Awesome work.

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @Broominator07
    @Broominator07 3 года назад +15

    One bug I noticed is that when you tilt the camera to look at far down as you can, this reduces movement speed because of the use of a rigid body moving in the direction of the camera.

    • @zenpresentt
      @zenpresentt Год назад

      How did you fix t?

    • @4bot
      @4bot Год назад +5

      @@zenpresentt In the PlayerLocomotion script, you have to change the HandleMovement() method; change "moveDirection = moveDirection * movementSpeed;" to "moveDirection = moveDirection.normalized * movementSpeed;"

    • @jaydenstrudel
      @jaydenstrudel 8 месяцев назад

      omg thank you actual lifesaver@@4bot

    • @carlosmarques6067
      @carlosmarques6067 7 месяцев назад

      YOU ARE MY HERO@@4bot
      but I don't know why make .normalized if moveDirection was already normalized two lines up XD

  • @concernedcitizen9101
    @concernedcitizen9101 9 месяцев назад

    For some reason in the top of the playermanager script I did not have public class playermanager. If you randomly stumble upon this I hope to have saved you some headache. Thank you btw Sebastian. Great video.

  • @epicdoggames9667
    @epicdoggames9667 3 года назад +2

    Much easier to understand the layermask concept in this tutorial than in the dark soul tutorials. Thank you so much. What’s next? Falling and jumping?

    • @SebastianGraves
      @SebastianGraves  3 года назад +3

      I believe sprinting, walking and running will be done in the next video! After that one, falling and jumping :^)

  • @hristoborisov3713
    @hristoborisov3713 3 года назад +1

    holy fuck you are the best, i forgot tutorials can be actually useful and mindful of possible mistakes and unclear code

  • @olegbebrovich3000
    @olegbebrovich3000 Год назад +1

    Small update with an issue when camera is clipping (going backwards in direction towards camera).
    Its happening because of Shperecast goes True by casting on the camera it self. It happens because the Collision offset is Player and Default whereas Camera Manager, Pivot and etc has the same Default layer. So to fix this you simply need to add a new Layer for walls on your level.

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @E-nfileexe
    @E-nfileexe Год назад +1

    Just in case no one noticed it like I did for about 3 hours XD
    For the Camera Collision
    DONT FORGET TO DRAG the Main camera into the Inspector for the Camera manager : Camera Transform
    Or else it wont move the camera when colliding
    He does say to do that in the video but ONLY when he was typing out the Public Transform
    He didnt state it at the end when he was testing out the camera because he also added the line in the Awake function to grab it instantly. XD

    • @nedsmamitag8518
      @nedsmamitag8518 Год назад +1

      my camera still passing through walls :( how to fix that ?

    • @duelz9366
      @duelz9366 Год назад +1

      @@nedsmamitag8518 Same thing is happening to me lmao

  • @jedayboi6714
    @jedayboi6714 5 месяцев назад

    Thank you so much for making this! Now I can make a game about a chicken with a sword fighting people who want to steal their eggs

  • @enriquer658
    @enriquer658 3 года назад +3

    Hi man, first of all thank you, this series is everything I have been looking for. I won't lie I'm learning on my own, clocking 8+ hours a day for the past 2 1/2 months learning programming, c# and of course Unity as well as other things, but you nailed it where other have failed, giving me a sense of order and how to approach this task of creating a character controller from scratch, so once again I think you. However, I did came up with a problem, everything works fines except for the camera. i encountered 2 issues. One my camera can still go trough walls so it does bounce off if I am at a distance, but if I literally place the player next to the wall, it doesn't bounce it goes into the wall and then comes out as long as I move it out. The other issue i came up with is when looking up with the mouse or the joystick while moving forward, the camera moves too close to the player to a point where he player actually disappears from view, and from there if you stop, and look down, the actual player, that is the character model itself has rotated as if laying down to look up at the sky even after constraining the rigidbody on its xyz axis. I do have a picture of this issue if there is a way for me to get it to you. I do have to mention a couple of things, my walls are made from single blocks streched out unlike yours which is multiple blocks, and on the other hand my model/character is the ybot from mixamo and I'm using the adventures locomotion pack which up to this point I haven't had any problems with, well unless you count out the fact that I forgot to bake Y position on the idle animation in the beginning and that actually caused my player to float around a bit but since that, all of my animations have been baked to their respective recommended positions by unity, looped and set to humanoid rigs. So any help is much appreciated, I think it may be related to minimunCollisionOffSet values and such but I'm not too sure since I'm just beginning to grasp theses concepts, anyways sorry for the love letter, and once again thank you for the great content!

  • @sC-br6hb
    @sC-br6hb Год назад +5

    if collision doesn't work
    1. cameraCollisionRadius 0.2f
    2. check both Collision layers Default and Player
    3. try away from the wall

    • @MrGarfield83
      @MrGarfield83 Год назад +2

      1: In my case, the ray went in the wrong direction.
      You can visually draw the ray using the Follow method:
      Debug.DrawRay(cameraPivot.position, direction * Mathf.Abs(targetPosition), Color.green);
      Add this method above the if-statement of Physiks.ShpereCast call.
      If you want to check the length of the ray, add the DrawRay method below the if statement of ShpereCast.
      2: Set the collision radius smaller than 2f, for example: 0.2f - 0.5f are good values.

  • @diggerfdf
    @diggerfdf 3 года назад +1

    As I use to say, Unity is not difficult, but it's complex. There are loads and tons of easy small bits that you must remember how to use and glue them together. I have a huge trauma with camera codes. Your code is a kick ass one. Thanks again. But everytime I spend almost 1 hour following a camera tutorial, I fell my Life force fading away, like I'm losing a few years of my life.
    Time and Thousands lines of code later I think if all of this couldn't be solved with ONE SINGLE WORD.
    I immediately shout "WHY THE F#%$^ JESUS CHRIST LICKING TADPOLES NONE USES CINEMACHINE! AHUHAUHAUAHUAH
    Since we are in the learning path, I suggest we gather into the Discord Server and try to redo this tutorial with Cinemachine.
    But hell yeah! It's a kick ass code for a camera inside the Dark Souls project. Nice Tutorial. The code is still fuzzy on my mind, but we got another stone at the Quaternion, Rotation, Position wall... THANKS A THOUSAND, ONCE MORE!

  • @AlexGorlik
    @AlexGorlik 3 года назад

    Amazing Thank you very much can't wait for more!

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @purpleguyfromfnaf0
    @purpleguyfromfnaf0 Год назад +3

    im having an issue where the camera wants to quickly move towards the player bc theres so much time between the character moving and the camera catching up, so it treats it as an object to have to close in on i think? im not sure where the issue is

    • @doctorEeeviI
      @doctorEeeviI Год назад

      yeah i think i'm having the same problem. like, when i run towards the camera, the camera jumps forward into my character as though the camera is colliding with something... let me know if you find a fix.

    • @Aggroknight62
      @Aggroknight62 10 месяцев назад

      There's a comment just a bit down from this one that has the fix. Just remove the Player tag from the collision layers in Camera Manager. That should stop the camera from clipping out the player.

  • @BadApple-um7vb
    @BadApple-um7vb 2 месяца назад +1

    if hope you can put long code in gist, looks like i miss something the rorate its not working

  • @JoskeVR
    @JoskeVR 4 месяца назад +2

    the camera goes around the player but when I look up or down its only my cam that moves

    • @MattuFarlygard
      @MattuFarlygard 2 месяца назад

      I was having the same issue too but that's because I did both Y and Z for Camera Pivot and it caused this issue.
      You have to set the Y for Camera Pivot (how high the camera will be) and the Z for the Main Camera (how far back is the camera). For this tutorial just set the Camera Pivot Y to 1.7 and Z to 0, then for Main Camera ensure the Y is still 0 but the Z to -3

  • @Denny0707
    @Denny0707 11 месяцев назад

    My brain is burning after this video, But... IT WORKS!!!!!!! THANKS!

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @abrandon99
    @abrandon99 Год назад +2

    hey ya'll i have an issue where if you walk towards the camera aka "when the vertical input is negative", the camera clips to the head. This issue is supper annoying so I just took off the player layer from the Collision Layers parameters. idk if anybody with the same issue solved this a while back.

    • @doctorEeeviI
      @doctorEeeviI Год назад

      yeah, i'm having the same problem. i dunno why it's happening, but thats a good fix- i'll do that too

    • @Aggroknight62
      @Aggroknight62 10 месяцев назад

      You legend, I was scratching my head on how it was happening. Thanks so much for the fix!

  • @JuffeGuffe
    @JuffeGuffe 3 года назад

    Snappy camera, awesome!

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @duelz9366
    @duelz9366 Год назад +2

    For those wandering why you did everything in the script yet your camera still passes through objects and doesn't detect a collision:
    Ensure the Camera Pivot transform position Y = 1.8
    AND
    Main Camera transform position z = -3
    My mistake was setting the y and z positional offset in the camera pivot gameobject. As a result the SphereCast method was not triggering maybe because the camera was spawned into a collision with the camera pivot since they were on top of each other.

    • @mcb3920
      @mcb3920 Год назад +1

      Thanks, I wasn't sure why collision wasn't working and this was exactly it.

    • @ct3027
      @ct3027 Год назад

      didnt work for idk why
      @@mcb3920

  • @Szogun_
    @Szogun_ День назад +1

    how can i make look around when press right button on mouse?

  • @HelpingPanda
    @HelpingPanda 3 года назад +3

    Cleaner way to set rotation values (in my opinion) would be to just set them directly, instead of saving them in a bunch of unnecessary variables. :)
    Ex:
    lookAngle += inputManager.cameraInputX * cameraLookSpeed;
    pivotAngle += inputManager.cameraInputY * cameraLookSpeed;
    pivotAngle = Mathf.Clamp(pivotAngle, minPivotAngle, maxPivotAngle);
    transform.rotation = Quaternion.Euler(0, lookAngle, 0);
    cameraPivot.localRotation = Quaternion.Euler(pivotAngle, 0, 0);

  • @0LIE
    @0LIE Год назад +1

    a movimentação tá muito parecida com a do GTA SAN ANDREAS, bateu uma nostalgia...

  • @metinbatuhanozucan5358
    @metinbatuhanozucan5358 Год назад +3

    if you see inside the walls you should change camera collision radius
    from 2f to 0.2f
    public float cameraCollisionRadius = 2f; // old one
    public float cameraCollisionRadius = 0.2f; // new one
    Also from the camera manager inspector in unity editor. The values must be same with code.

  • @kunalpandey1327
    @kunalpandey1327 5 месяцев назад

    if your camera is glitching when you are running towards the camera then uncheck the player layer in camera's "collision layers"

  • @bigsimpin5722
    @bigsimpin5722 2 года назад +1

    Why are we separating the tweaking of our camera's height and depth into two different gameObjects (Camera Pivot and the Main Camera itself)? Seems pointlessly convoluted.

  • @fateshow5303
    @fateshow5303 2 года назад

    all amazing vids, so well explained

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @tit7267
    @tit7267 3 года назад +2

    Hey dude I love your videos, great work you are sharing. I just wondered if the reason for the character stuttering could be the cameraManager.FollowTarget() inside LateUpdate(). I moved it to the end of FixedUpdate() and set Interpolate to None. Maybe Rigidbody does not need to interpolate movement between different frames then because it is in line with the physics updates (whereas using LateUpdate is not in line with physics -> interpolation needed)? Keep on learning dudes!!!

  • @WeLoveCreatingGames
    @WeLoveCreatingGames 2 месяца назад +1

    Hi! for some reason, I can't figure out where the error is... The camera continues to pass through the walls(

  • @conorchambers8671
    @conorchambers8671 3 года назад +2

    Thanks again for the tutorial, I'm really trying to grasp coding and the way your setting each script out means I actually remember what each line of code is for/doing! One issue I seem to have is my character judders when I'm holding W and move the camera left or right, so the player forward is snapping to the camera forward, I tried working it out but no luck, I'm guessing I need to smooth out the rotation some how??
    edit, I changed (transform.position = targetRotation) to (transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, cameraLookAngleSpeed * Time.deltaTime);) as it seems to have help a bit.

  • @Andrew-tl9gk
    @Andrew-tl9gk Год назад +4

    Why didnt you use Cinemachine?

  • @Properpeanut
    @Properpeanut 3 года назад +5

    This is an great tutorial series. Thanks a lot for taking your time to make them and explain so much. A like and a sub from me.
    But... I have a problem with the camera collision. When the camera hits a wall, it is pushed through the wall to the outside of the wall instead of it being kept inside. I tried tinkering with the radius and the offset and even with thicker walls. I watched the episode three times and can't see any typing errors. Help?

    • @thetra00
      @thetra00 3 года назад

      got the same problem
      not solved :( sorry

    • @pedrogrossmann4135
      @pedrogrossmann4135 3 года назад +2

      @@thetra00 I had a simillar problem, fixed it putting cameraCollisionRadius to 0.2 instead 2, he even say that in the video but I totally didnt heard it lol.. hopefully it will help someone else :D

  • @LAGinator429
    @LAGinator429 Год назад +2

    anyone, if the camera is still clipping through the walls change the camera collision radius to 0.2f

  • @zachgough91
    @zachgough91 Год назад +2

    Loving the series, I was wondering if by any chance you have run into the problem where the up and down for the camera movement is inverted (i.e. i move my mouse up and the camera goes down and vice versa)

    • @JohnnyAardvark66
      @JohnnyAardvark66 Год назад +1

      I've had this problem and fixed it by using: cameraInputY = -cameraInput.y; in the InputManager.cs

  • @omgcyanide4642
    @omgcyanide4642 3 года назад +2

    Yes finally

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @BMOthePOTATO
    @BMOthePOTATO 5 месяцев назад

    i have appeased the youtube algorithm gods

  • @bobbybriggs7126
    @bobbybriggs7126 2 года назад +1

    cool tutorial, I don't see why we want to check for collision with our player though. gave me a problem where the camera would snap inside the model because of the camera follow speed when running towards the camera

    • @garybuchert7005
      @garybuchert7005 2 года назад

      Did you happen to find a solution for this? I found that removing the player from the collision layers didn't stop this problem from happening (camera snapping inside the player when running towards the camera).
      EDIT: Changed my camera follow speed to 0.01 and it got rid of the issue for me.

  • @DiegoGrajales12
    @DiegoGrajales12 3 года назад

    Nice work brother!! I rlly like these :D

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @marcinkujawski3524
    @marcinkujawski3524 2 года назад

    Great tutorial. Thank you so much!

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @gamernabilalabadi6240
    @gamernabilalabadi6240 5 месяцев назад

    still Gold

  • @NBGTZ
    @NBGTZ 2 года назад +2

    When i go to where the camera is (press the S key) the camera just go inside the player when i release the S key its back to normal and when i pressed the other buttons its work fine only problem is with the S key
    please help

    • @garybuchert7005
      @garybuchert7005 2 года назад +2

      Having the same issue. Any luck fixing?
      EDIT: Changed my camera follow speed to 0.01 and it got rid of the issue for me.

    • @jonbelbawlout
      @jonbelbawlout 2 года назад +1

      remove "player" from camera collision layers

  • @hiryu70
    @hiryu70 3 года назад +1

    Comment "Camera looking up and down" must be for pivotAngle if I understand all right.

  • @jeystark13
    @jeystark13 3 года назад +2

    Hello! Impressive tutorial, could you answer a little question? I need my character not to change direction when the camera rotates, but I can't understand what part of the code is doing this, could you help me? Greetings, keep it up! I'm sure subscribers will rain

    • @theghostfour
      @theghostfour 2 года назад

      Comment to keep me Updated to this topic

  • @Jebbles1
    @Jebbles1 3 года назад +2

    For some reason, the camera clips into my player character's head every time I press play after we did the layers and set collisions and I'm not sure what's up. Other than that, fantastic video I look forward to binging the rest.

    • @jamesdubs1015
      @jamesdubs1015 3 года назад +2

      type this line in your start void:
      deafultPosition = cameraTransform.position.z;

  • @cptray-steam
    @cptray-steam 3 года назад +3

    Hey for some reason camera movement with my mouse is faster than that with my gamepad's right stick. Is there a way around this or is it covered later on?

  • @NhanThanh-ib9wb
    @NhanThanh-ib9wb 3 года назад

    So underrated video!

  • @elderdiscord7662
    @elderdiscord7662 2 года назад +1

    Ah shit, It is going to be a challenge to code wallrun using this system xD

  • @GUSRG
    @GUSRG 3 года назад +4

    Hey man, great videos, do you plan to add some 3rd person combat in the future too?

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

  • @gerardogarcia737
    @gerardogarcia737 Год назад

    How to make the camera rotation does not stop when it reaches the limit of the window when doing build.
    By the way excellent tutorials very grateful for the excellent work you do.

  • @Gabriel_-_-_
    @Gabriel_-_-_ 3 года назад +2

    I have an error and I don't understand pls help
    Assets\Scripts\CameraManager.cs(82,133): error CS1503: Argument 6: cannot convert from 'float' to 'int'
    and this is the script:
    if (Physics.SphereCast(cameraPivot.transform.position, cameraColisionRadius, direction, out hit, Mathf.Abs(targetPosition), collisionLayers))

    • @cptray-steam
      @cptray-steam 3 года назад

      Make sure the collisionLayers variable is of type LayerMask and not float.

  • @klutz6557
    @klutz6557 2 года назад +2

    Your series is excellent!
    I have one question to ask. my camera is still going through walls the collision detection is working fine and it also jumps off but still if I move around it still goes inside walls.

    • @changming8227
      @changming8227 2 года назад

      I'm having the same issue

    • @DeBlueGOD
      @DeBlueGOD 2 года назад

      I believe it is because the camera manager is at the floor while the camera itself is further back. I had to change my camera manager where the pivot and camera would be.

  • @AiDesign426
    @AiDesign426 2 года назад

    The problem with the camera is because the Rigidbody is updated in Fixed update and the camera in update or late update and they have diferent timing calculations.
    Thx for the tutorial btw :D

  • @samuelkodio5849
    @samuelkodio5849 7 месяцев назад

    Thanks for this series. I discovered it several days ago and am currently enjoying every bit of it.
    Right now, there's a little problem I face : the camera's vertical movement makes it rotate on itself instead of orbiting around the target. I may have done something wrong but everything in the code looks fine to me.

    • @JoskeVR
      @JoskeVR 4 месяца назад

      could you please send the script cus mine doesn't work I'm begging you, just copy and paste.

    • @JoskeVR
      @JoskeVR 4 месяца назад

      I have the same exact issue did you fix it yet

  • @ДарьяЗолотова-б1ъ
    @ДарьяЗолотова-б1ъ 10 месяцев назад

    Thank you very much for the video!
    I encountered the following problem: when the character moves away from the original point, the camera radius becomes huge and rises to the top
    Sorry for any mistakes :(

  • @00CrossFire1
    @00CrossFire1 4 месяца назад

    Not sure why, I have no Errors and i followed the vid and yet my camera wont go up and down and changing the pivotspeed and lookspeed doesnt do anything...

  • @rusydirosli9423
    @rusydirosli9423 Год назад

    The camera follow was absolutely awesome, but the camera rotation was not my type when working with third person game... I mean it work but not smoothly like camera follow... I think there something to manipulate with camera rotation after using euler... Maybe i could use slerp but it will interrupt between another interpolation(smoothdamp)... Hmmm

  • @neisanland2503
    @neisanland2503 2 месяца назад

    the cameraManager script prevents my character from moving, it plays the animations, it rotates and all but prevents it from moving. when i remove the cameraManager from the camera, the character moves. its a problem i cannot seem to understand and may have to use a different tutorial for camera stuff.

  • @MCCAIN867
    @MCCAIN867 3 года назад +1

    Very good

  • @yahallobenjamin2354
    @yahallobenjamin2354 Год назад +1

    How do you stop the camera from seeing through walls?

  • @ayushsidam289
    @ayushsidam289 3 года назад

    Thanks for the video 😀👍🏻

  • @rayleigh8536
    @rayleigh8536 3 года назад +1

    hello I have some sort of problems, the collision works fine but when its not colliding it pushes my camera far away what seems to be the cause?
    EDIT:
    i found my mistake it was a darn semicolon misplacement in the if statement for sphere cast

  • @ropuerta3181
    @ropuerta3181 3 года назад +1

    Hey man that serie is awesome, for you're next video can you explain: How to make footsteps?? pls

    • @mattlepage1898
      @mattlepage1898 3 года назад +3

      Easyway: add an AudioSource to the player,, put it a footstep clip, on loop and start on awake, disable it by default.
      In the player script, create a bool "isMoving" (something like that) and a reference to the Audiosource, like with the rigidbody
      make the bool true when inputs are not = 0 and false when it's = 0, at last enable the audisource when "isMoving" it's true!
      You got your footsteps sound when your moving!

  • @zenpresentt
    @zenpresentt Год назад

    When I look down as far as I can and move, my movement slows down, I think it’s cuz the force is directed in the forward direction of the camera.

  • @LuisBazanCOI
    @LuisBazanCOI 2 года назад

    Is there a particular reason of why you don't use the Cinemachine package? Loving these videos!

  • @CrownlessKing37
    @CrownlessKing37 Год назад

    thank you for the lessons

  • @Van-Leo
    @Van-Leo 3 года назад +2

    hey, i was wondering if you could post the code for the camera somewhere? ive been testing out a lot of different camera tutorials and i think it would be easier for me to understand if i just had the code infront of me to test ad poke at, otherwise ill just copy whats in the video, but it would be like the third time for me.

    • @PommeVerte47
      @PommeVerte47 3 года назад

      You can access it if you are participating to the pateron

  • @zachlafave1914
    @zachlafave1914 2 года назад +1

    @11:56 the playerControls.PlayerMovement.Camera cannot be found. Ive checked the name a thousand times. It founds the Movement just fine but not the camera I dont understand

  • @devonchapman4927
    @devonchapman4927 3 года назад

    Hi buddy, great tutorials so far, watched a few of them (not all and not in order) just trying to see if this is what I need, so far so good, have you covered on top of the normal movements the character moving in the direction of the camera if that makes sense? Also, I read that you will be showing how to do this video with cinemachine instead of manually when can we expect this to release?
    Once I have some time I have your dark souls vids bookmarked ready haha.

    • @SebastianGraves
      @SebastianGraves  3 года назад +1

      Hey dude, the player does move in respect to the camera's facing direction. I have however, made no intention to showcase this with Cinemachine, as it's relatively simple to set up!
      Cheers!

  • @Makkara91
    @Makkara91 8 месяцев назад

    Thanks a lot!

  • @llamakorn
    @llamakorn 3 года назад +2

    i want to add some code that resets the camera behind the player when ever I hit R3. anyone know how to help me with this?

    • @kys1721
      @kys1721 3 года назад

      In start method save the transform position of the camera in variable and when you hit R3 set the position of the camera with the variable

  • @Jayhonas
    @Jayhonas 3 года назад

    Loving the series!
    Is the code going to be available somewhere, Sebastian (like via the Discord, or github perhaps)?
    It can be a little tricky to go back and watch videos an extra 1-2 times to catch what part of the code I missed.
    If not - I totally understand :). Thanks for the awesome series.
    The Dark Souls Project was a little too advanced for me skill-wise, but this one is just perfect.
    Keep it up!

    • @SebastianGraves
      @SebastianGraves  3 года назад +1

      Code is available on my Patreon for series supporters!
      I am glad you are enjoying the series dude :^)
      Cheers!

  • @Zanetros
    @Zanetros 3 года назад +1

    I followed every step in the last video but, when i hit play the only animation that displays is the running animation, the idle and walk dont work

  • @cryzzzz
    @cryzzzz Год назад

    Is there a posibilty that the camera orbits more, so if you drive forwards and look right that you still go in the same direction but look to the side?

  • @spiderdlh9905
    @spiderdlh9905 9 месяцев назад

    Hi I know im late to the show What a great tutorial so far i ve followed your video step by step and come across some problems and that is the camera falls to the players feet andthe player cant look up or down

  • @fireball6906
    @fireball6906 2 года назад +1

    I did everything you said in the video but the CameraCollision does not work for me do you know maybe what are the possible reasons for this?

    • @sirmayor4710
      @sirmayor4710 2 года назад

      Hi, did you somehow manage to resolve you problem ? Thank you

  • @tiagoalvarengacorsato5143
    @tiagoalvarengacorsato5143 2 года назад

    amazing collision better than cinemachine

  • @maximsandu7780
    @maximsandu7780 2 года назад +2

    HELP PLEASE COLLISION DONT WORKING
    code:
    public class CameraManager : MonoBehaviour
    {
    InputManager inputManager;
    public Transform cameraPivot;
    public Transform cameraTransform;
    public Transform targetTransform;
    private Vector3 cameraFollowVelocity = Vector3.zero;
    public LayerMask collisionLayers;
    public float cameraFollowSpeed = 0.2f;
    private Vector3 cameraVectorPosition;
    public float lookAngle;
    public float pivotAngle;
    public float maximumPivotAngle = 35;
    public float minimumPivotAngle = -35;
    public float minimumCollisionOffset = 0.2f;
    public float cameraCollisionOffset = 0.2f;
    private float defaultPosition;
    public float cameraCollisionRadius = 2;
    public float cameraLookSpeed = 2;
    public float cameraPivotSpeed = 2;
    private void Awake()
    {
    inputManager = FindObjectOfType();
    targetTransform = FindObjectOfType().transform;
    defaultPosition = cameraTransform.localPosition.z;
    cameraTransform = Camera.main.transform;
    }
    public void HandleAllCameraMovement()
    {
    FollowTarget();
    RotateCamera();
    HandleCameraCollisions();
    }
    private void FollowTarget()
    {
    Vector3 targetPosition = Vector3.SmoothDamp
    (transform.position, targetTransform.position, ref cameraFollowVelocity, cameraFollowSpeed);
    transform.position = targetPosition;
    }
    private void RotateCamera()
    {
    Vector3 rotation;
    Quaternion targetRotation;
    lookAngle = lookAngle + (inputManager.cameraInputX * cameraLookSpeed);
    pivotAngle = pivotAngle - (inputManager.cameraInputY * cameraPivotSpeed);
    pivotAngle = Mathf.Clamp(pivotAngle, minimumPivotAngle, maximumPivotAngle);

    rotation = Vector3.zero;
    rotation.y = lookAngle;
    targetRotation = Quaternion.Euler(rotation);
    transform.rotation = targetRotation;
    rotation = Vector3.zero;
    rotation.x = pivotAngle;
    targetRotation = Quaternion.Euler(rotation);
    cameraPivot.localRotation = targetRotation;
    }
    private void HandleCameraCollisions()
    {
    float targetPosition = defaultPosition;
    RaycastHit hit;
    Vector3 direction = cameraTransform.position - cameraPivot.position;
    direction.Normalize();
    if (Physics.SphereCast(cameraPivot.transform.position, cameraCollisionRadius, direction, out hit, Mathf.Abs(targetPosition), collisionLayers))
    {
    float distance = Vector3.Distance(cameraPivot.position, hit.point);
    targetPosition =- (distance - cameraCollisionOffset);
    }
    if (Mathf.Abs(targetPosition) < minimumCollisionOffset)
    {
    targetPosition = targetPosition - minimumCollisionOffset;
    }
    cameraVectorPosition.z = Mathf.Lerp(cameraTransform.localPosition.z, targetPosition, 0.2f);
    cameraTransform.localPosition = cameraVectorPosition;
    }
    }