INTERACTION - Making an RPG in Unity (E02)

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

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

  • @photonman54
    @photonman54 7 лет назад +364

    the .Slerp function allows the Quaternion to eat hot soup with out burning its mouth.

  • @ArnoldsKtm
    @ArnoldsKtm 7 лет назад +8

    These series are so good. Not too noobish but advanced enough for a person that knows programming but hasn't made games. Gives general idea of what to look into and figure out why.

  • @thebluereason
    @thebluereason 4 года назад +54

    I know I'm actually progressing when a Brackeys video starts to make sense

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

      i wrote good code and sphere not working how fix it???

  • @joshdecker3334
    @joshdecker3334 3 года назад +155

    When you follow along perfectly with a unity tutorial
    Unity: YOU ARE WRONG NOW SUFFER

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

      oww yes i know what you mean XD

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

      You might be running a different version of Unity, or a different version of C#

    • @dibaterman
      @dibaterman 3 года назад +7

      I feel more comfortable playing Russian roulette, at least I've never failed at that.

    • @obsidianflight8065
      @obsidianflight8065 3 года назад +7

      @@dibaterman you never lose, until you do, but then you can never lose ever again

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

      i wrote good code and sphere not working how fix it???

  • @Coreycoreyomg
    @Coreycoreyomg 6 лет назад +26

    The tutorials are great. But someone who is really interested in the programming aspect, I would like a little explanation on the programming side. The "Why" is more important to me rather then just do this and it works.

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

      i wrote good code and sphere not working how fix it???

  • @Pentasoniczound
    @Pentasoniczound 6 лет назад +55

    I'm pretty sure that a Quaternion Slerper is the final boss in some game... Something in the Sci-fi horror genre...

    • @thebadger4040
      @thebadger4040 4 года назад +1

      It's the final boss of coding.

  • @TheTeaTycoon
    @TheTeaTycoon 7 лет назад +4

    There is an error with the auto braking, if your stopping distance is below ~3 unity will sometimes forget about it altogether and you will end up inside the sphere. Just turn off autobraking when you set the stopping distance, and turn it back on when you unfocus.

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

    I just managed to get everything working without an issue on the second try, lol. Thank you so much for the information packed content. Took me some time to get my head around it but the process of making the game is so satisfying! Thank you so much for making these tutorials, I'm sure a lot of games in the future will owe their existence to this playlist!

  • @ResoCoder
    @ResoCoder 7 лет назад +11

    Whoah! The quality of this tutorial is top notch. Thanks Brackeys!

  • @LC-xq7zi
    @LC-xq7zi 4 года назад +12

    For those the gizmos wire sphere doesn't show up, can try to include the "using System.Collections" tag in Interactable
    I am using 2019.4.4f1

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

      The fix for me was changing
      void OnDrawGizmoSelected ()
      to
      void OnDrawGizmos ()

  • @IntenseMX
    @IntenseMX 4 года назад +1

    As a beginner, this was a tough one, a lot of just rewriting, but it all came together in the end. Thanks!

  • @km_youtube23
    @km_youtube23 7 лет назад +89

    For anybody having a 'null' Interactable error when clicking the sphere, try removing the LayerMask from the Physics.Raycast parameters.

  • @Giorgi.Japiashvili
    @Giorgi.Japiashvili 6 лет назад +4

    Wow, this tutorial got advanced pretty fast. Gotta say, your videos are packed with content and everything is thoroughly prepared from your side which is a lot. I've seen Udemy courses which don't even come close to this quality, so thanks a lot! Also thanks to everyone who supports you on Patreon.

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

      i wrote good code and sphere not working how fix it???

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

    Awesome tutorial! I managed to convert this to work on my 2D game. The interactable script is the same but the player controller script is pretty much all changed.

  • @andreasrips4857
    @andreasrips4857 4 года назад +1

    man makes top tier things look so simple im scared for this man's power tbh

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

    I love this man from the bottom of my heart

  • @bloaa
    @bloaa 4 года назад +27

    Dipping into coding after a 14 year break. I really appreciate these videos, thank you man!
    Side note, is the max speed and efficiency a core programmer personality trait? I have yet to see a good coder that doesn't seem like he's on cocaine when he works haha. Hallowed be the space bar.

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

      When you're incessantly rewriting code and testing it, you get used to where the buttons are and want to do it as quickly as possible so you can continue working, so I'd say yes, yes it is. ;)

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

      @@MisterShnig i wrote good code and sphere not working how fix it???

  • @ChumperDumper
    @ChumperDumper 7 лет назад

    Thought I should mention that when you set a boolean, you don't have to set it to false. A bool will always default to false when being declared. You should only initialize it if you want to set it to true by default. Keeps the code a bit cleaner.

    • @SubjektDelta
      @SubjektDelta 7 лет назад +2

      Setting it to false makes it easier to understand for others! And it doesn't muddle up the code that much..

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

    I can officially confirm that the player controller has a Fundamental bug that is preventing the game from acting in 2021. I even took the code and modified it to be exactly like his on github. DO NOT BOTHER TRYING TO FINISH THIS IN 2021. Basically the error that fundamentally prevents some of the advanced parts of the controller code, and will not interact with the object. I am going to try and download the finished version from git, and see if that even works.

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

    still the best and shortest tutorial :D

  • @gitwilma4286
    @gitwilma4286 6 лет назад

    I had some coding projects due last minute. Thanks, Brackeys, You guys make coding so easy!

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

    this is the first time i see this power of codeing and the idea of wt you do is clear and you let us now wt you do and its like easy thx man i new here and i happy to see your work

  • @Saleca
    @Saleca 4 года назад +1

    great series, you are definitely my go to for learning unity stuff!! practical, comprehensive and pleasant, thanks!

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

    For those the gizmos wire sphere doesn't show up yellow color, i use function OnDrawGizmos()
    private void OnDrawGizmos()
    {
    Gizmos.color = Color.yellow ;
    Gizmos.DrawWireSphere(transform.position, radius);
    }

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

      i wrote good code and sphere not working how fix it???

  • @alexanderelert2877
    @alexanderelert2877 7 лет назад +2

    You are the King of Unity :) All of your tutorials are so good and very understandable. Thank you a lot Sir!

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

      i wrote good code and sphere not working how fix it???

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

    If you are having an issue with the right click target, remember to remove the layer check on the conditional for the portion of the player controller where you right click.

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

      Thank you, I was looking for this!

  • @luislodosm
    @luislodosm 7 лет назад +3

    Great pace of the tutorial.

  • @williamc8395
    @williamc8395 6 лет назад +3

    Not sure if anyone is getting this, but I'm having trouble "focusing" on the interactable and I'm pretty sure I didn't leave anything out. This is what I have:
    [RequireComponent(typeof(playerMotor))]
    public class playerController : MonoBehaviour {
    public Interactable focus;
    Camera cam;
    playerMotor motor;
    void Start () {
    cam = Camera.main;
    motor = GetComponent();
    }
    void Update () {
    if (Input.GetMouseButtonDown(1))
    {
    Ray ray = cam.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;
    if (Physics.Raycast(ray,out hit))
    {
    motor.MoveToPoint(hit.point);
    RemoveFocus();
    }
    }
    if (Input.GetMouseButtonDown(0))
    {
    Ray ray = cam.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;
    if (Physics.Raycast(ray,out hit))
    {
    Interactable interactable = hit.collider.GetComponent();
    if (interactable != null)
    {
    SetFocus(interactable);
    }
    }
    }
    }
    void SetFocus(Interactable newFocus)
    {
    focus = newFocus;
    motor.MoveToPoint(newFocus.transform.position);
    }
    void RemoveFocus()
    {
    focus = null;
    }
    }

    • @wildlifegmd2422
      @wildlifegmd2422 6 лет назад +2

      you have to add 100 behind the ray like this
      if (Input.GetMouseButtonDown(0))
      {
      Ray ray = cam.ScreenPointToRay(Input.mousePosition);
      RaycastHit hit;
      if (Physics.Raycast(ray,out hit, 100))

    • @fikrilazuardi2049
      @fikrilazuardi2049 5 лет назад +2

      @@wildlifegmd2422 thank you, god bless u, i just figured it out how the f i cannot select the sphere, then i tried to change the layer to a ground. and its magically happened.

    • @tarfariclark7130
      @tarfariclark7130 5 лет назад

      Fikri Lazzuardi I was so stuck until I read this. Thanks

  • @gamingnation5468
    @gamingnation5468 7 лет назад

    AHA! In 10:38 you said "on defocused" when you wrote "new focus"! I KNEW NOONE COULD BE THAT GODLY AS TO BE PERFECT IN EVERY SINGLE WAY!

  • @HumanitiesFunda
    @HumanitiesFunda 6 лет назад

    You are just awsome.recently i am working on a cool open world game project . i have learnt a lot from you

  • @cptant7610
    @cptant7610 7 лет назад +8

    Wouldn't it be more robust to implement an interactable interface?
    That way interactable functionality can be added more flexibly without having to derive from the same class.

    • @alexmyshinsky9474
      @alexmyshinsky9474 6 лет назад

      In case of NPC's interact with objects, they wont be able to use interface, you know ;)

    • @FoxMageKitsune
      @FoxMageKitsune 5 лет назад +1

      @@alexmyshinsky9474 I believe CPTANT is talking about an interface as in the programming technique, not a GUI element. An interface in C# is a specific programming feature that could potentially be used instead of making a parent class to inherit from.

    • @amogh2101
      @amogh2101 4 года назад

      @@alexmyshinsky9474 Generally in Brackeys tutorial, he does the optimizing stuff later. Idk if he has done it for this though.

  • @KaletheQuick
    @KaletheQuick 7 лет назад +20

    Since you are doing a collab with Seb, can you show you two using the new Unity Collaboration system?

    • @jamesiagary1388
      @jamesiagary1388 5 лет назад

      KaletheQuick was the day you were going to come home

    • @Deadwindshadow
      @Deadwindshadow 5 лет назад +4

      @@jamesiagary1388 What are you talking about? lol tf

  • @gordonmctague4225
    @gordonmctague4225 7 лет назад

    Oh Mister Brakey.....I been trying to learn Unity for a while now an kind of understand the tutorials but sheeeeeeeeeeeet you do go through it real fast so I slow the play back speed and you sound real cool as a darlek... Keep up the good work.

  • @mshaheerhaider
    @mshaheerhaider 4 года назад

    I noticed something in your tutorials, you choose the hardest way to do things. I know you love maths and complexity but you should keep it simple.

    • @user-th8nx4cp7w
      @user-th8nx4cp7w 4 года назад

      He is already doing things in the most efficient and easy way for people to understand, I could make this tutorial way harder but the code run faster. I do know what you mean by "easy", but the code will be not clean, not efficient and run slow.

  • @bernardb2348
    @bernardb2348 6 лет назад

    hey buddy. I dont think you should put the stopping distance in the stop followind target() back to 0f. You should always want your stopping distance to be the same (non changing). just saying. THX for the amazing videos

  • @margaritabotero2787
    @margaritabotero2787 7 лет назад +2

    Thanks, Brackeys :) Your videos are amazing. Always smiling and with a positive attitude - that makes a great teacher. Thank You, Sensei and Master of Unity :)
    [If somebody needs....
    Problems with a rotation -> As I was moving the sphere around the character, I began to notice that the character did not rotate. It rotates when I move with the left-click but not when following the interact-able with right-click.
    Solution (for my case) -> I completely forgot to add FaceTarget(); to the void Update() section.]

    • @nicholasflint9480
      @nicholasflint9480 4 года назад

      Omfg you saved my life (and my computer), I've been stuck on this for hours, thank you!

  • @user-th8nx4cp7w
    @user-th8nx4cp7w 4 года назад

    everytime I start learning from a new tutorial series I am usually a bit confused, and after finishing the entire tutorial series and comes back thinking "oh, this make so much sense "

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

      I just click away because a function called interactable with an argument called interactable containing a variable class named interactable and an instance of it called interactable when creating an interactable object turns my brain to mush.

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

    I've been looking for this for so long, thank you so much!

  • @Chokwik
    @Chokwik 4 года назад

    didn't first get the Focus set to sphere when clicking it, but started working after i changed Sphere's Layer to Ground..
    idk how wrong it is, but just glad to see something happen :D

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

      delete movement mask from the other one

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

    If you are using cinemachine virtual camera and raycasting is not working, try using the FixedUpdate() method instead of Update()

  • @DannyMakesStuff
    @DannyMakesStuff 7 лет назад

    After my exams I will start working thorugh this!
    Also started making tutorials about 2D stuff in Unity, you are a great inspiration Brackeys!

    • @DannyMakesStuff
      @DannyMakesStuff 7 лет назад

      what?

    • @lovelesstsukashi8786
      @lovelesstsukashi8786 7 лет назад

      He probably means you're hot xD
      (which you are, tbh)

    • @DannyMakesStuff
      @DannyMakesStuff 7 лет назад

      Loveless Tsukashi okay 😅 thank you ?

    • @lovelesstsukashi8786
      @lovelesstsukashi8786 7 лет назад +1

      Np haha checked your tutorial and you also have a beautiful voice and good content to teach. So, +1 subscriber!

    • @DannyMakesStuff
      @DannyMakesStuff 7 лет назад +1

      Loveless Tsukashi cool thanks! Maybe I should start show myself like brackeys 😂

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

    Thanks for making this series now I can make my own RPG game!

  • @rolegames500
    @rolegames500 4 года назад +1

    I ended up getting stuck on the player not moving after it focused the sphere. The problem seemed to be that I wrote updatePosition, instead of updateRotation. I believe I pressed enter to auto fill it, took a bit to find the problem since it was throwing no errors.

  • @carlsagan9808
    @carlsagan9808 7 лет назад

    Bookmark 6:28, also thanks, Brackeys, for the good video

  • @Donkeydog
    @Donkeydog 4 года назад +5

    Great tutorial! I do have one thing wrong. When i click on the sphere it doen show up in the inspector under player. When i drag it in there and click somewhere else it disappears so the defocus works in just cant get it to focus. I put on the ground layer and it didnt work also tried static also didnt work anyone have the same issue?

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

      I have the same problem

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

      If anyone still facing the same issue, remove movementLayer from if statement in right mouse click section. Worked for me.

  • @dylloop
    @dylloop 6 лет назад +6

    Ran into an interesting error thought i would share the fix. sometimes i would get an error saying "Look rotation viewing vector is zero." it would just spam the console. Usually .normalized should make it so this doesnt happen but if the number is really small unity makes it 0 instead of 1/ so to fix this I added an if statement before the look rotation and it ended up looking like this.
    void FaceTarget ()
    {
    Vector3 direction = (target.position - transform.position).normalized;
    if (direction.x != 0f || direction.z != 0f)
    {
    Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0f, direction.z));
    transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
    }

    }

    • @ZachThurmond
      @ZachThurmond 6 лет назад +1

      This is the only issue I have ran into since following his tutorials. Thanks :p

    • @UrBoyBlueJake
      @UrBoyBlueJake 6 лет назад

      Dude thank you! i had no clue what was wrong!

    • @kartech6079
      @kartech6079 5 лет назад

      Thanks so much, it means a lot!

    • @laok
      @laok 5 лет назад

      thanks

    • @ZynisterActs
      @ZynisterActs 5 лет назад

      THANK YOU! I found some resources online that gave a similar solution but I couldn't figure out the exact conditions in the if statement. This was also the only issue I had in his tutorials

  • @eugenepaul4952
    @eugenepaul4952 4 года назад

    For those who is right clicking on the object and nothing happens, try putting the right click method above the left click method

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

    ***SOLVING THE PROBLEM OF INTERACTION WITH THE SPHERE ***
    Unfortunately, this was not mentioned in this video and is very important for the correct operation of the script!
    When you insert a 3D Sphere object into the scene, it has a "default" layer marked in the inspector. For the interaction to work properly, you must change its layer to the same one as "Ground"

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

    for anyone wanting to do this by the end of the year who've just started, don't bother with raycasts and shit. just use a collision and pass the collider to the player script using OnTrigger2D round an area, and cast the collider object as the player script.

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

      how do i do that

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

      @@hexadecimals1093 if you put a big collision box ONTOP of your actual collision box for a door/chest/thing-to-interact-with, you can check in your player script for "OnTriggerEnter2D" (tick isTrigger for collider). This means you can store the object that you can interact with from there (look up Collision structure)

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

      @@roganjosh6220OMG dude you ARE a legend. Thank you man!

  • @amilismurfs
    @amilismurfs 7 лет назад

    I really love the clicking and typing sound :)

  • @maximusthegreatest
    @maximusthegreatest 6 лет назад +1

    This works up until you put the FollowTarget logic inside a check to see if Focus != null like this: void SetFocus(Interactable newFocus) {
    if(newFocus != Focus) {
    if (Focus != null) {
    print("Running focus");
    Focus.OnDefocused();
    Focus = newFocus;
    motor.FollowTarget(newFocus);
    }
    }
    It wil pass the first check but Focus is equal to null because its not declared with anything. So it wont activate the FollowTarget method. It instead goes to newFocus.OnFocused(transform); which doesnt return anything hence Focus will never be not null. Any ideas on how to fix?

  • @subucni22
    @subucni22 5 лет назад +2

    Not sure if it will help anyone now but don't forget to add the Intractable Script to the Sphere. :)

  • @matthewkeron1448
    @matthewkeron1448 5 лет назад +5

    dude your videos are awesome!
    If i had one piece of feedback its that you talk / type very fast at some points and i need to constantly go back a few seconds to take in what you said lol
    Other than that they're great! Keep it up

  • @WreckedRevival
    @WreckedRevival 7 лет назад

    EDit: I drew a Sphere instead of a WireSphere lol but either way..something you could implement in a game somehow I'm sure;
    couldn't see through interactable Radius bubble.... but if you want to change color/alpha easily in the Editor window, In the Interactable script make a public Color radiusColor; then in OnDrawGizmosSelected() { Gizmos.Color = radiusColor;}

  • @RichardCheese-go2rh
    @RichardCheese-go2rh Год назад

    Still works for me so far thanks

  • @Filmedbycjj
    @Filmedbycjj 6 лет назад +3

    when i go into play mode and click on sphere my player doesnt detect it as a focus. what have i done wrong? It will not focus it, it will not follow it, the player just does nothing when i click or it walks through the sphere's space when i left click.
    EDIT: I fixed it. the sphere needs to be on the ground layer :)

    • @Demineaux
      @Demineaux 4 года назад

      This helped. I was losing my mind. Thanks :)

    • @Exori
      @Exori 4 года назад

      Thanks

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

      delete movement Mask

  • @preeteshshirkar5451
    @preeteshshirkar5451 4 года назад

    You could create a bool for special interaction and create a get method that will return interaction transform if bool is true or own transform if the bool is false

  • @aidendawes3560
    @aidendawes3560 7 лет назад +4

    Hi Brakeys, your tutorials are awesome, I learn so much!!! Please can you do a save system tutorial?

    • @tylerguitar75
      @tylerguitar75 6 лет назад +1

      I know this wouldnt be as good as a tutorial, but you can look up the unity docs on XML output as a starting point. E.g. output your player's transform to a file and read it on start.

    • @pitaya4151
      @pitaya4151 5 лет назад

      Y'all, check out PlayerPrefs. It's super easy!

  • @danisob3633
    @danisob3633 7 лет назад

    YAY i was waiting 7 years for this

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

    I don't know if anyone is still watching these, but my player stops moving after the interaction, any idea why?

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

      Same issue. If you figured it out I'd love to hear what you found.

  • @GeroTroXx
    @GeroTroXx 7 лет назад +4

    Why don't you use colliders(as triggers) with their methods OnTriggerEnter, OnTriggerExit for interactables?

    • @Sharal3D
      @Sharal3D 4 года назад

      :D exactly what i used to do lol

  • @punchdarkwing1591
    @punchdarkwing1591 6 лет назад +5

    I need Help! My player sets the sphere to interactible in the public float but does not follow it, how do I fix this?

    • @ewwkl7279
      @ewwkl7279 6 лет назад +1

      I've got the same problem....anybody please help

    • @jaywilliams9721
      @jaywilliams9721 4 года назад

      Same, have you got a fix?

  • @ababdulhai823
    @ababdulhai823 5 лет назад +1

    Thanks For You Teacher I've made everything True With Your Helps Really Thanks

  • @KreizLandGames
    @KreizLandGames 7 лет назад +10

    All Your lessons are really helpfull even if I live in Russia !!)) Thanks!!

  • @geameliai4500
    @geameliai4500 4 года назад

    I built my own terrain out of simple shapes and after following along some more I suddenly couldn't get the code to register the main plane anymore, so the entire walking code failed.
    For anyone suffering a similar issue: Just delete your ground and plop down a new one and bake a new navmesh. I tried for hours to find the slightest typo before realizing it was not the code that was jank, but the terrain.

  • @Kulbaru
    @Kulbaru 4 года назад +4

    Maybe someone still reads this, i have a Problem after clicking the Interactable. At first my Player moves at exactly the same position i clicked but after i Interacted i have somekind of not clickable parts around my player. I can not move him if i click at a Distance of 1.6 or less. I tested this by meassuring the distance between my hit.point and my player.position. If someone has any Idea where the problem is please help.

    • @user-th8nx4cp7w
      @user-th8nx4cp7w 4 года назад

      Could it possibly be that your clicking on your players collider

  • @robardknoxfield1604
    @robardknoxfield1604 6 лет назад +2

    While I love brackeys and find them helpful, I dont know how to even start going about an interaction script. Using a player asset that came precoded to walk using WASD which is great cause I dont want to do a point and click game, but since Brackeys interaction code references its own movement script idk what to do

    • @Sharal3D
      @Sharal3D 4 года назад

      oneyear too late :D i think you need to take input andjust add to transform of the object idk im just learning stuff

  • @chenariana3482
    @chenariana3482 4 года назад +1

    agent.StopingDistance is not working.... My player wont stop when he reach the radius of the enemy... Any ideas?

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

    the interactables need a collider for this to work FYI

  • @kevinwang7601
    @kevinwang7601 7 лет назад +7

    Woohoo, I'm so excited to continue working on this game! Currently I have run into an issue with the "Interactable" object. The error I'm getting is CS0103: the name "Interactable" does not exist in the current context. Any suggestions?

    • @Mayur7Garg
      @Mayur7Garg 6 лет назад

      It would be easier to find the reason of error if you could specify the line where the error is being generated.

    • @GzE1337
      @GzE1337 6 лет назад

      u missed the part on 14:10 where he tells you to use the own transform object from the circle as his interaction transform

  • @nuttzy99
    @nuttzy99 5 лет назад

    If the yellow wireframe doesn't appear for you, then your script might have an error. Check the console tab to see what the error is. If there is no error, you may have spelled the method name incorrectly. OnDrawGizmosSelected has two s's

    • @chenariana3482
      @chenariana3482 4 года назад

      Gizmos is working but my player did not stoping when he reach the radius of the enemy...

  • @kahluaandsam
    @kahluaandsam 4 года назад

    If anyone is having a problem with the player not going from None(Interactable) to Sphere(Interactable), for me it worked when I added the FollowTarget function. I have no idea why.

  • @clopes87
    @clopes87 5 лет назад +1

    @5:32 why do we set the argument of FollowTarget to newFocus instead of the variable focus that we declared right above it?

  • @resonatebob4495
    @resonatebob4495 7 лет назад

    I've been waiting for something like this, thanks!

  • @andreutormos7210
    @andreutormos7210 7 лет назад +1

    Ep 2!!! Thanks Brackeys :D

  • @leepisin8211
    @leepisin8211 7 лет назад

    how can u be such an awesome teacher ??

  • @SamNBCA
    @SamNBCA 7 лет назад +4

    I think I broke something, after i right click on the sphere, If I right click on the terrain I don't move anymore.
    *Update: I think i found the issue, in PlayerController.CS
    in the press right mouse button down logic...
    I commented out :
    if (interactable != null)
    {
    SetFocus (interactable);
    }
    That seemed to resolve the issue.

    • @mikedupree2690
      @mikedupree2690 7 лет назад +2

      Same issue. If you comment that line out you no longer interact with the Object.. Curious what I did wrong

    • @SamNBCA
      @SamNBCA 7 лет назад +3

      If you look at this script
      github.com/Brackeys/RPG-Tutorial/blob/master/RPG%20Project/Assets/Scripts/PlayerController.cs
      * * Note: ignore lines 25 & 26 (it's for a later tutorial)
      It looks like the functionality has changed
      on the right cliick, there is no...
      motor.MoveToPoint(hit.point);
      it's only part of the left click, looks like left is going to be for moving and right is going to be for picking up items.
      So remove motor.MoveToPoint(hit.point); from your right click and you should be caught up (it's likely something that is addressed in a future tutorial.
      hope that helps.

    • @skarrlive1616
      @skarrlive1616 7 лет назад +2

      bro i have the same issue i need ur help apparently unity says
      NullReferenceException: Object reference not set to an instance of an object
      PLayermotor.FaceTarget () (at Assets/Scripts/PLayermotor.cs:48)
      PLayermotor.MoveToPoint (Vector3 point) (at Assets/Scripts/PLayermotor.cs:30)
      PlayerController.Update () (at Assets/Scripts/PlayerController.cs:25)

  • @jakespencer1993
    @jakespencer1993 5 лет назад +1

    Code seems to match perfectly but i can not left click on the item, focus on it, and have him move to it. It focuses, just will not move.

    • @dan_kotsu
      @dan_kotsu 5 лет назад

      I have the same issue. Pretty frustrating.

  • @giovannicescutti1751
    @giovannicescutti1751 7 лет назад

    Why Brackeys is so awesome?

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

    9:55, check if player is in range

  • @dutchdoggo
    @dutchdoggo 4 года назад

    for those saying its to fast paced, pause at every line of code and write it up.

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

    So I got to where I can click to set focus but it wont focus on what I right click on. Ran a debug and it was in fact clicking on things. I'm thinking it's because of the layerMask... and it was... so this is an odd issue - I have to set the sphere to ground layer for it to not be ignored.

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

    At point 8:32 in the video I am getting the error message "NullReferenceException: Object reference not set to an instance of an object"
    I believe this being caused by the 'Focus' Interactable, because when I right click the sphere the error is no longer logged, and when I deselect the sphere the error is logged again.
    Is there a way for me to fix this? Or am I stuck with it?

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

    Great tutorials! I have though a problem, I cannot select the Spehere on the Default Layer, it only works if it is part of the Ground layer. It eludes me why it is like that, from your video it looks fine on the Default layer. The movement mask seems to have no impact on your interactables.

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

      I had the same problem as well and i just made a different layer called Interactables and on player movement mask i made it so that it had Ground and Interactables selected, seems to work fine now but im not sure if it will break in the future. hopefully that helps ya!

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

      Hey so i messed around with it further and if you copied the if statement for movement like he did and only changed the GetMouseButtonDown, make sure to delete the movementMask in the arguments of the if statement for physics.Raycast! this will make it so that when checking for interactables it wont be solely be based on the ground layer and check any object in the scene.

  • @rafirafchaines8316
    @rafirafchaines8316 7 лет назад +10

    Guys!I've just found that Interactable objects need to be on Ground layer!

    • @yego211
      @yego211 6 лет назад +1

      Or you can remove the movementmask variable on your "if" argument since that is the one trapping the layermask.

    • @moonlightshadowpony
      @moonlightshadowpony 5 лет назад

      thank you! i just spent 30 minutes looking through my code because i was certain i missed a semicolon or accidentally misspelled a variable or something to make my right mouse button not work.

    • @chenariana3482
      @chenariana3482 4 года назад

      But it still wont stop when the player reach the edge of the radius of the interactable object..

  • @QDurlstonP
    @QDurlstonP 7 лет назад +1

    Additional Request for the future, is there any chance you could look into performance management on completion of this project? I'm talking about how you'd swap between low and high poly models, terrain and assets based on distance (whether to use Async-scenes or to run checks through script(s) checking object distances.
    I get this doesn't really fit to the scale of the project (at least the intro footage shows a relatively small environment, such that scene management probably won't be a problem). Just a request for features that may have been forgotten/left out of this tutorial due to its scope.
    I look following this tutorial in the near future. Keep up the awesome work!

    • @ChumperDumper
      @ChumperDumper 7 лет назад

      Take a look at tutorials for Occlusion Culling and LOD (Level of Detail). Both of these are built into Unity (although there are slight shit tbh when it comes to clean use of them). I don't fully understand why you would want to use Async to check object distance? If you want to keep it efficient, run it on a separate thread. :P

    • @qwerty81808
      @qwerty81808 7 лет назад

      Running it on a separate thread would, by definition, make it asynchronous.

    • @QDurlstonP
      @QDurlstonP 7 лет назад

      ChumperDumper when I first started learning about scene management, I wound up on a tutorial suggesting breaking up a scene through Async-loading different sections of the scene based off hitboxes (so for example, loading the other side of a bridge as you start to cross it, removing the scene where you came from as you leave the far side of the bridge). It's just one way of keeping the object-count low in a large world.
      I hadn't heard of the Occlusion Culling and LOD settings built into Unity before reading your comment (I honestly thought there was no built-in features for asset-detail management), so I'll go research them now. Thanks!

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

    for people using 2019 unity + the code is not working you have to use 2018 (at least i hope so)

  • @ajmracer1756
    @ajmracer1756 4 года назад

    No one may ever see this but it is worth a shot. So I am currently following this tutorial and the StopFollwingTarget section is not working. If anyone has any ideas or has found a solution I would love to here them. Thanks

  • @MrGenbu
    @MrGenbu 5 лет назад +2

    the problem for so that the player did not move on rigth click was that i wrote
    agent.updatePosition
    instead of
    agent.updateRotation
    in methods FollowTarget & StopFollowingTarget

  • @Boreality_
    @Boreality_ 4 года назад

    Gone through it twice, assuming its a version problem; but
    has anyone found that the system works perfectly, except once I've interacted with something (prints debug.log("INTERACT")), I cant interact with it again, even when I removed the focus, even when I focus on a new object with the interactable script?

  • @farruxhewson6111
    @farruxhewson6111 7 лет назад +4

    Love your videos!!! Can you do video about copyright, and how to protect your games or assets. Thanks a lot :)

  • @immortalhamster1645
    @immortalhamster1645 4 года назад

    When your watching a tutorial series for the inventory and you have to make sure that your FPS controller doesn’t moving the wrong direction because you shot an interactable.

  • @UsernameNULL755
    @UsernameNULL755 6 лет назад +1

    One question - why make an Intractable parent class for all the stuff that probably has nothing else in common? Doesn't it make more sense to make something like an interface? Is that even possible in unity?
    I'm coming from UE4 perspective, so this approach with attaching scripts to objects is still weird to me.

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

    For those who had a problem interacting with the mouse right click (to appear on the Focus box), try setting the esphere to Ground, hope im doing the right thing, if im wrong please leave a comment

  • @SovakaKindred
    @SovakaKindred 7 лет назад +3

    Question: Why did you not use 'Transform.LookAt' instead of creating your own version of it?

    • @tylerguitar75
      @tylerguitar75 6 лет назад +3

      Transform.LookAt would snap the rotation. Doing it his way with slerp lets us do it smoothly at our specified speed

  • @potatokinggaming3532
    @potatokinggaming3532 7 лет назад +2

    the radius will not show in the inspector
    using UnityEngine;
    [SerializeField]
    public class NewBehaviourScript : MonoBehaviour {
    public float radius = 3;
    void OnDrawGizmosSelected()
    {
    Gizmos.color = Color.yellow;
    Gizmos.DrawWireSphere(transform.position, radius);
    }
    }

    • @potatokinggaming3532
      @potatokinggaming3532 7 лет назад

      did you make it a public

    • @potatokinggaming3532
      @potatokinggaming3532 7 лет назад

      i dont know how far you are :P
      void OnDrawGizmosSelected()
      {
      if (interactionTransform == null)
      interactionTransform = transform;
      Gizmos.color = Color.yellow;
      Gizmos.DrawWireSphere(interactionTransform.position, radius);
      }
      or
      void OnDrawGizmosSelected()
      {
      Gizmos.color = Color.yellow;
      Gizmos.DrawWireSphere(interactionTransform.position, radius);
      }

    • @EmanuelLopesS2
      @EmanuelLopesS2 6 лет назад

      your public class, you need to change this name to your script name. you have NewBehaviourScript, change this

    • @punchdarkwing1591
      @punchdarkwing1591 6 лет назад

      The issue is it's 3f; not just 3;

  • @sgyffysgyffy4736
    @sgyffysgyffy4736 7 лет назад +1

    Alright! Great work on your videos!
    If you were to make text-based Unity tutorials, I would gladly become a Patreon supporter. Unity is in dire need of more HQ text-based tutorials.

  • @tylerguitar75
    @tylerguitar75 6 лет назад

    This is such a good tutorial. Now I just need to go watch some coroutine videos...

  • @sideboxhd1806
    @sideboxhd1806 6 лет назад +1

    How can we do to interact with an item by pressing F for example instead of mouseclick please ?

  • @itzplaymind5551
    @itzplaymind5551 7 лет назад

    I waited so long for this but it was worth it ;D