How to make camera follow the player in a 3D Game in Unity 2019.4

Поділитися
Вставка
  • Опубліковано 19 сер 2024

КОМЕНТАРІ • 90

  • @tutorialsEU
    @tutorialsEU  3 роки тому +7

    🎮 Unity Masterclass - Master game development by building enjoyable games from scratch: bit.ly/3YJWe0N

    • @dan-h7r
      @dan-h7r 3 роки тому

      my camera offset keeps changing when i play. why does this happen

    • @dan-h7r
      @dan-h7r 3 роки тому +1

      nvm moved the camera and its better

    • @dan-h7r
      @dan-h7r 3 роки тому

      @@kabirthaddeus3688 sus

  • @thomasedwardking7286
    @thomasedwardking7286 Рік тому

    Broo you are literally my freaking messiah right now. You rule, Boss

  • @CosmicComputer
    @CosmicComputer 3 роки тому +4

    I bought the C# master class on Udemy and I love it, thanks for all this great content. If you ever decided to make a tutorial on a rigidbody character controller, that would be awesome!

  • @nancytc214
    @nancytc214 3 роки тому +1

    Thank you!! 🙏🙏 it finally worked, after all those youtube tutorials and google searches

    • @nameios6895
      @nameios6895 2 роки тому +1

      Just put the camaera inside the player its so easy

    • @nancytc214
      @nancytc214 2 роки тому

      @@nameios6895 Ooh yeah thank you!

  • @user-rl2ox1bu4c
    @user-rl2ox1bu4c Рік тому

    5:20 I was watching with a smile waiting for you to exit play mode :D I was expecting how far you would go with that 😂 Yeah, that happens.

  • @catherinefister6666
    @catherinefister6666 Рік тому

    This helped me tremendously and I really appreciate the thoroughness and the explanations on what you were showing in C#.

  • @abramharder3787
    @abramharder3787 2 роки тому +2

    Yeah but it doesn't stay behind player

  • @ikemuoma8495
    @ikemuoma8495 Рік тому

    Just tried it again, and it works; all good. Thanks 👍

  • @bynishant9616
    @bynishant9616 3 роки тому +4

    I litreally copied and pasted his code and guess what it does not work nothing he wrote is valid in December 2020 is it the same with everyone?

    • @trisharpgaming9328
      @trisharpgaming9328 3 роки тому

      It can be everything. Maybe you typed in something wrong, or there is a conflict with the scripts name. describe the issue in your code and i will try to help you :)

  • @jazzallen6537
    @jazzallen6537 3 роки тому +4

    Here I was struggling to make the character move not on the axis’s but by what way it’s facing (for months) and here you are who taught me how to do it in seconds

  • @PhysicsMosses
    @PhysicsMosses 3 роки тому

    Thanks a lot man 😘 I was like...
    "What the hell he is explaining slowly"
    But It's beginner friendly 🥰 It helped me sure will help more people.

  • @chocolateer2
    @chocolateer2 2 роки тому

    That was so useful. Holy crap. Thank you very much. Happy that you even explained slerp and lookat. 10/10

  • @ethicalmarcus3782
    @ethicalmarcus3782 3 роки тому +1

    best tutorials

  • @portasonic1
    @portasonic1 2 роки тому

    YOU SAVED MY LIFE, THANK YOU

  • @PRodi_
    @PRodi_ 4 роки тому +5

    Great tutorial! btw. do you have in plans to make top down 3 person hovercraft controller tutorial?

    • @tutorialsEU
      @tutorialsEU  4 роки тому

      We are planning on adding a click to move tutorials. Is this what you mean?

    • @PRodi_
      @PRodi_ 4 роки тому +1

      @@tutorialsEU I was thinking more about this: ua-cam.com/video/4HpC--2iowE/v-deo.html but with extra option to slide - wich I have controll how far my hovercraft is sliding

  • @crthamizhan1648
    @crthamizhan1648 2 роки тому

    Thx Bro

  • @ayushjha6560
    @ayushjha6560 2 роки тому +1

    Nice Video Sir

  • @munyamunya313
    @munyamunya313 3 роки тому +2

    nice tutorial i learned a lot but the camera si a bit bad i expected it to follow the direction of the player

  • @JuanSanchez-kd7nn
    @JuanSanchez-kd7nn 3 роки тому

    I love you bro! New sub :D

  • @ikemuoma8495
    @ikemuoma8495 Рік тому

    Good tutorial. But I did'nt notice any differnce implementing the LookAt feature. The Camera behaved exactly the same with or without implementing LookAt.

  • @rovicsuyat3222
    @rovicsuyat3222 3 роки тому

    Thank you very much!!

  • @christianhjortzberg2706
    @christianhjortzberg2706 3 роки тому +1

    Hallo, why is the camera shaking, what I am doing wrong ?

  • @KoenigOne
    @KoenigOne 2 роки тому +1

    bruh i literally copied everything you did and my capsule is moving randomly i cant even control it
    Edit: i changed the capsule to a cube and disabled gravity option and it worked

  • @ErodonTV
    @ErodonTV 2 роки тому

    Great video , please let me know if yall know how to lock the camera behind the player

  • @ourybah7633
    @ourybah7633 3 роки тому

    I liked the pictures behind

    • @tutorialsEU
      @tutorialsEU  3 роки тому

      Finally someone noticed them :)

  • @aleksandrnamanyuk9169
    @aleksandrnamanyuk9169 Рік тому

    The link is not working for the blog post .. :(

  • @serbask354
    @serbask354 3 роки тому

    Thank You!!!!

  • @kapillibossa2570
    @kapillibossa2570 3 роки тому

    thank you so much

  • @stevengaming55
    @stevengaming55 2 роки тому

    How to make camera controls like if the player isn't happy with the camera i made but another player is can i make like a zoom in and out or let the player rotate the camera?

  • @user-cf2ef1hp6y
    @user-cf2ef1hp6y Рік тому

    im getting alot of errors but il find it out

  • @gameswithelectron
    @gameswithelectron 2 роки тому

    For me Video started from 8:32

  • @oneRella
    @oneRella Рік тому

    I want the camera to stay behind the player like a 3rd person game. This is just tracking the player, not following.

  • @tenbezmatky8472
    @tenbezmatky8472 3 роки тому +1

    idk why but the script aint working for me

  • @mrecksie
    @mrecksie 3 роки тому

    cant believe I watched 10 minutes of this video just to watch you copy paste the first result for "unity 3d camera follow player" line by line

  • @itssugsy6250
    @itssugsy6250 3 роки тому

    Hello so if i press a or d i fly up and down with this script help.

  • @1onGoogle
    @1onGoogle 8 місяців тому

    If your camera is not following the curve road/ direction wise=>using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class CameraFollow : MonoBehaviour
    {
    public Transform target;
    public Vector3 cameraOffset;
    public float smoothF = 0.5f;
    public bool lookAtTarget = false;
    void Start()
    {
    cameraOffset = transform.position - target.transform.position;
    }
    void LateUpdate()
    {
    // Get the road's right direction
    Vector3 roadRight = GetRoadRightDirection();
    // Calculate the desired position based on the road's curve
    Vector3 newPos = target.transform.position + roadRight * cameraOffset.x + cameraOffset.y * Vector3.up + cameraOffset.z * Vector3.forward;
    // Smoothly interpolate to the new position
    transform.position = Vector3.Slerp(transform.position, newPos, smoothF);
    // Optionally, make the camera look at the target
    if (lookAtTarget)
    {
    transform.LookAt(target.position);
    }
    }
    Vector3 GetRoadRightDirection()
    {
    // Find the road by tag or assign it directly in the Inspector
    GameObject road = GameObject.FindWithTag("Road");
    if (road != null)
    {
    return road.transform.right;
    }
    else
    {
    Debug.LogError("Road not found. Make sure the road has the correct tag.");
    return Vector3.right; // Default to global right direction
    }
    }
    }

  • @kayra_iydrss
    @kayra_iydrss 3 роки тому

    thank youu

  • @JoshuaSpeedcubing
    @JoshuaSpeedcubing 2 роки тому

    how do you set the camera offset to 0? i want a first person game

  • @dropgamehub135
    @dropgamehub135 3 роки тому +1

    Transform and vector could not found error cs0246 what to do

    • @trisharpgaming9328
      @trisharpgaming9328 3 роки тому

      do you still have the problem? then send the errormessage in here.

  • @orio69
    @orio69 3 роки тому +2

    Camera still vibrates a lot. How to fix?

    • @maliksaraanasim5404
      @maliksaraanasim5404 3 роки тому

      Remove slerp maybe? xD

    • @trisharpgaming9328
      @trisharpgaming9328 3 роки тому +2

      In the video, there is a variable named "smoothFactor" and its set to a value of 0.5f. Simply give smoothFactor a higher value, try something like 3f or 5f.
      This should remove the vibration / stutter / jitter. Hope that helps :)

  • @Yannnus
    @Yannnus 3 роки тому +2

    Tutorial about camera starts at 5:26

  • @ghaidaa2794
    @ghaidaa2794 Рік тому

    Can you copy the code ?

  • @muminoloruntola2146
    @muminoloruntola2146 4 роки тому +3

    Please I really need help on my programming instructions on building a shopping app

    • @tutorialsEU
      @tutorialsEU  4 роки тому

      Hi Mumin. This sounds like an interesting idea. I will run a survey to find out what app the students in my course are most interested in and I will add a shopping app to the options.

    • @muminoloruntola2146
      @muminoloruntola2146 4 роки тому

      @@tutorialsEU how can I be a student please

    • @tutorialsEU
      @tutorialsEU  4 роки тому

      @@muminoloruntola2146 by joining my Android Masterclass. www.udemy.com/course/android-kotlin-developer/?couponCode=YTANDROID0820

    • @muminoloruntola2146
      @muminoloruntola2146 4 роки тому

      @@tutorialsEU Ok thank you

    • @muminoloruntola2146
      @muminoloruntola2146 4 роки тому

      @@tutorialsEU I hope we also have your contact for personal help after the masterclass

  • @quirix6980
    @quirix6980 2 роки тому

    none of the code that you send worked for me ;-; please help😐

  • @mohamedyaosama5674
    @mohamedyaosama5674 3 роки тому +1

    😭😭😭please say for me i got much erorrs say for me how i make this erorrs out

  • @BellaNateCouple
    @BellaNateCouple 4 роки тому +1

    Hey, I'm trying to get the camera to follow my player in just a simple rolling ball game, but when I enter the code, it says "Assets\CameraMove.cs(8,12): error CS0246: The type or namespace name 'transform' could not be found (are you missing a using directive or an assembly reference?)" do you know how to fix this? awesome tutorial by the way

    • @timewastertoasterman6736
      @timewastertoasterman6736 3 роки тому

      The same comes up on mine

    • @trisharpgaming9328
      @trisharpgaming9328 3 роки тому +1

      I know it has been a while but if you still need help, here is my answer to this ^^
      Unity works with C#, and C# is Case sensitive, wich means, you have to type in the words correctly.
      As i see in the error message, youre trying to create a Transform variable.
      But instead of "Transform" you say "transform".
      Simply replace "transform" with "Transform" :)

  • @adwardyudin
    @adwardyudin 3 роки тому

    I couldn't get this script to work.... I have a scene and character already made. adding the script to the camera and the target to follow does nothing at all. I tried both before and after adding the smoothing. It is as if the script doesn't exist at all.....
    Can someone help?

    • @foreignwarren7361
      @foreignwarren7361 2 роки тому

      same problem here

    • @nameios6895
      @nameios6895 2 роки тому

      @@foreignwarren7361 Just drag the camera into the player

    • @samfrank910
      @samfrank910 Рік тому

      @@nameios6895 I know this is an older comment but maybe their game isnt first person

  • @astronomik8528
    @astronomik8528 2 роки тому

    Or just drag your Camera inside of your Player (Cube for instance)

  • @jake-gs4do
    @jake-gs4do 3 роки тому

    how do i get to that code screen?

    • @greasychickenugget4410
      @greasychickenugget4410 2 роки тому

      Hey I'm really late, but if you still want to know you need to install visual studio. It's free and you can link it to Unity or something.

    • @jake-gs4do
      @jake-gs4do 2 роки тому

      @@greasychickenugget4410 thx 😍🥰😘

  • @dkordy
    @dkordy 2 роки тому

    bUT PLEASE SOMEONE on this stupid you tube to explain how to folow prefab object ? i heve player selection on one scene and when i go to other scene my camera folowing characters spawing object but my player is moving and camera staying to folow targeting game object-do you understand me what i ask? please i cant find help enyware on whole stupid you tube!

  • @Tom-if2du
    @Tom-if2du 2 роки тому

    my character can go through the walls

  • @pixeldude594
    @pixeldude594 3 роки тому

    Naruto Uzumaki 🔥

  • @baget3053
    @baget3053 3 роки тому

    Joe you say...

  • @CuongemTet
    @CuongemTet Рік тому

    hay qua

  • @vixtion9180
    @vixtion9180 3 роки тому +2

    Me after seeing yandere dev's code
    14:16
    *If statements, we meet again*

  • @dwied3703
    @dwied3703 2 роки тому

    Mouse X

  • @rbanister100
    @rbanister100 Рік тому

    Add you kidding?

  • @user-kf4pe7kr2v
    @user-kf4pe7kr2v 3 роки тому

    Llu