When you follow along perfectly with a unity tutorial Unity: YOU ARE WRONG NOW SUFFER
@axouny3 жыл бұрын
oww yes i know what you mean XD
@quippits32013 жыл бұрын
You might be running a different version of Unity, or a different version of C#
@dibaterman3 жыл бұрын
I feel more comfortable playing Russian roulette, at least I've never failed at that.
@obsidianflight80653 жыл бұрын
@@dibaterman you never lose, until you do, but then you can never lose ever again
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@photonman547 жыл бұрын
the .Slerp function allows the Quaternion to eat hot soup with out burning its mouth.
@calvinz91264 жыл бұрын
Y E S
@immortalhamster16454 жыл бұрын
Lmfaoooo
@Sakdos3 жыл бұрын
@AstroFahl Parent may have no mouth
@athakmaurya1642 жыл бұрын
wtf
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@thebluereason4 жыл бұрын
I know I'm actually progressing when a Brackeys video starts to make sense
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@ArnoldsKtm7 жыл бұрын
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.
@ResoCoder7 жыл бұрын
Whoah! The quality of this tutorial is top notch. Thanks Brackeys!
@Coreycoreyomg6 жыл бұрын
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.
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@Giorgi.Japiashvili6 жыл бұрын
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.
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@ilias_from_ilios4 жыл бұрын
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!
@Pentasoniczound6 жыл бұрын
I'm pretty sure that a Quaternion Slerper is the final boss in some game... Something in the Sci-fi horror genre...
@thebadger40404 жыл бұрын
It's the final boss of coding.
@km_youtube237 жыл бұрын
For anybody having a 'null' Interactable error when clicking the sphere, try removing the LayerMask from the Physics.Raycast parameters.
@byebyegiomar6 жыл бұрын
thx bro
@chris-iy9yt6 жыл бұрын
Thanks alot!
@alihaydargubatov27906 жыл бұрын
Mine problem was however calling OnDefocused twice inside SetFocus
@wildlifegmd24226 жыл бұрын
Thank, You. saved me alot of time here mate
@abrahammartinez68945 жыл бұрын
Most underrated comment
@gamingnation54687 жыл бұрын
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!
@LC-xq7zi4 жыл бұрын
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
@tylerserrette3 жыл бұрын
The fix for me was changing void OnDrawGizmoSelected () to void OnDrawGizmos ()
@IntenseMX4 жыл бұрын
As a beginner, this was a tough one, a lot of just rewriting, but it all came together in the end. Thanks!
@alexanderelert28777 жыл бұрын
You are the King of Unity :) All of your tutorials are so good and very understandable. Thank you a lot Sir!
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@andreasrips48575 жыл бұрын
man makes top tier things look so simple im scared for this man's power tbh
@TheTeaTycoon7 жыл бұрын
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.
@bloaa4 жыл бұрын
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.
@MisterShnig4 жыл бұрын
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. ;)
@elomoim92012 жыл бұрын
@@MisterShnig i wrote good code and sphere not working how fix it???
@gitwilma42866 жыл бұрын
I had some coding projects due last minute. Thanks, Brackeys, You guys make coding so easy!
@XURlMA3 жыл бұрын
I love this man from the bottom of my heart
@Saleca4 жыл бұрын
great series, you are definitely my go to for learning unity stuff!! practical, comprehensive and pleasant, thanks!
@NotNazuh3 жыл бұрын
I've been looking for this for so long, thank you so much!
@bobtgg7 жыл бұрын
Cant wait till the next episode...Great work as always
@alighanem84933 жыл бұрын
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
@KaletheQuick7 жыл бұрын
Since you are doing a collab with Seb, can you show you two using the new Unity Collaboration system?
@jamesiagary13885 жыл бұрын
KaletheQuick was the day you were going to come home
@Deadwindshadow5 жыл бұрын
@@jamesiagary1388 What are you talking about? lol tf
@gordonmctague42257 жыл бұрын
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.
@DannyMakesStuff7 жыл бұрын
After my exams I will start working thorugh this! Also started making tutorials about 2D stuff in Unity, you are a great inspiration Brackeys!
@DannyMakesStuff7 жыл бұрын
what?
@lovelesstsukashi87867 жыл бұрын
He probably means you're hot xD (which you are, tbh)
@DannyMakesStuff7 жыл бұрын
Loveless Tsukashi okay 😅 thank you ?
@lovelesstsukashi87867 жыл бұрын
Np haha checked your tutorial and you also have a beautiful voice and good content to teach. So, +1 subscriber!
@DannyMakesStuff7 жыл бұрын
Loveless Tsukashi cool thanks! Maybe I should start show myself like brackeys 😂
@phattrinhtan45623 жыл бұрын
still the best and shortest tutorial :D
@GausRothTutorials4 жыл бұрын
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.
@dylloop6 жыл бұрын
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); } }
@ZachThurmond6 жыл бұрын
This is the only issue I have ran into since following his tutorials. Thanks :p
@UrBoyBlueJake6 жыл бұрын
Dude thank you! i had no clue what was wrong!
@kartech60796 жыл бұрын
Thanks so much, it means a lot!
@laok5 жыл бұрын
thanks
@ZynisterActs5 жыл бұрын
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
@fonsly50774 жыл бұрын
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.
@darkdoom9072 жыл бұрын
9:55, check if player is in range
@ChumperDumper7 жыл бұрын
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.
@SubjektDelta7 жыл бұрын
Setting it to false makes it easier to understand for others! And it doesn't muddle up the code that much..
@dan_kotsu5 жыл бұрын
So i have my code exactly the way Brackeys has it but for some reason when i right click on the sphere it will not move to it but it will focus and recognize the object, any ideas?
@jakespencer19935 жыл бұрын
Same issue
@kenichibeveridge87185 жыл бұрын
Managed to get it working when I set the layer of the sphere to Ground. Not sure if it's meant to but it got that bit working.
@chenariana34825 жыл бұрын
Same, have no idea why mine is not working
@resonatebob44957 жыл бұрын
I've been waiting for something like this, thanks!
@Ninja1k17 жыл бұрын
never clicked notification so fast
@hamahed17784 жыл бұрын
likes go brrr
@matthewkeron14485 жыл бұрын
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
@danisob36337 жыл бұрын
YAY i was waiting 7 years for this
@dibaterman3 жыл бұрын
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.
@Classymarc3 жыл бұрын
Thank you, I was looking for this!
@carlsagan98087 жыл бұрын
Bookmark 6:28, also thanks, Brackeys, for the good video
@amilismurfs7 жыл бұрын
I really love the clicking and typing sound :)
@user-th8nx4cp7w4 жыл бұрын
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 "
@Kathayne6363 жыл бұрын
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.
@logoteam49984 жыл бұрын
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); }
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@cptant76107 жыл бұрын
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.
@alexmyshinsky94746 жыл бұрын
In case of NPC's interact with objects, they wont be able to use interface, you know ;)
@FoxMageKitsune5 жыл бұрын
@@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.
@amogh21014 жыл бұрын
@@alexmyshinsky9474 Generally in Brackeys tutorial, he does the optimizing stuff later. Idk if he has done it for this though.
@esotericdamian50293 жыл бұрын
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?
@rylanhrasko70536 жыл бұрын
k so I got a problem, my person wont interact with the object, no errors are popping up, any suggestions?
@jamesiagary13885 жыл бұрын
Rylan Hrasko then the next game you will love them you won’t get bored and they can not beat you
@khanyakubheka10204 жыл бұрын
right click
@funnyin41573 жыл бұрын
Thanks for making this series now I can make my own RPG game!
@chenariana34825 жыл бұрын
agent.StopingDistance is not working.... My player wont stop when he reach the radius of the enemy... Any ideas?
@andreutormos72107 жыл бұрын
Ep 2!!! Thanks Brackeys :D
@Filmedbycjj6 жыл бұрын
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 :)
@Demineaux5 жыл бұрын
This helped. I was losing my mind. Thanks :)
@Exori4 жыл бұрын
Thanks
@Chang0d3 жыл бұрын
delete movement Mask
@williamc83956 жыл бұрын
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; } }
@wildlifegmd24226 жыл бұрын
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))
@fikrilazuardi20496 жыл бұрын
@@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.
@tarfariclark71306 жыл бұрын
Fikri Lazzuardi I was so stuck until I read this. Thanks
@kevinwang76017 жыл бұрын
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?
@Mayur7Garg7 жыл бұрын
It would be easier to find the reason of error if you could specify the line where the error is being generated.
@GzE13377 жыл бұрын
u missed the part on 14:10 where he tells you to use the own transform object from the circle as his interaction transform
@punchdarkwing15916 жыл бұрын
I need Help! My player sets the sphere to interactible in the public float but does not follow it, how do I fix this?
@ewwkl72796 жыл бұрын
I've got the same problem....anybody please help
@jaywilliams97214 жыл бұрын
Same, have you got a fix?
@aza1ization7 жыл бұрын
sir, i feel like i've given up on all this coding and unity. its just too hard. i spend hours on end just trying to understand a function and it wont come to me. i dont know what to do
@arthos45517 жыл бұрын
aza1ization i highly suggest learning a base language first. Something like C/C++ or java. From there you will get a basic understanding of the fundamentals like loops, arrays, pointers, functions, ect. If you're having trouble with just knowing what function in the Unity libraries does then i suggest finding a compilation of explanations or backtrack to the original implementation of the function and see if the developers left any comments in their code with explanations. Sometimes even the software will explain what the function does if you hover over it but i don't think unity does this.
@mahmoudshatnawi61227 жыл бұрын
All good programmers felt the same at some point. I can help you with something if you want
@ResoCoder7 жыл бұрын
While I wouldn't suggest to hop into another language if you want to do Unity development, basic understanding of the language is much needed. Then just sit down and code. Really... I know it may sound weird but at some point it's just gonna "click" and you will begin to understand everything. So just "trust the process"! Stick to what you're doing, push forward and you will be really glad that you didn't give up later down the line. Good luck!
@elofkarlsson63437 жыл бұрын
Keep at it! There're no shortcuts to this. Programming is, or at least was for me, something that you just have to put the hours in programming yourself. Eventually it'll click. I gave up several times, but allways came back. Then during one of my attempts, it clicked.
@gmfCoding7 жыл бұрын
A function or method (they are the same thing) is something you can call/invoke to what i would call manipulate variables. All programming is, is checking what a variable is and or setting a variable to something. Nothing more nothing less. If you wan't you can think of a function as like a book (that you made or someone else made), every-time you read the book (call the function) it does what you/someone wrote in it. Function's are designed to cut down on code repetition. Functions make your game/application smaller in size. Hopefully this can clear things up. I have self taught my self programming since 13, i have been programming for 5-ish years now however most of that time wasn't programming. It's was only when i discovered Unity was when i start to get "Good". *Patience is also a massive key in learning programming, without it you are sure to fail.*
@mshaheerhaider4 жыл бұрын
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-th8nx4cp7w4 жыл бұрын
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.
@SovakaKindred7 жыл бұрын
Question: Why did you not use 'Transform.LookAt' instead of creating your own version of it?
@tylerguitar756 жыл бұрын
Transform.LookAt would snap the rotation. Doing it his way with slerp lets us do it smoothly at our specified speed
@roganjosh62203 жыл бұрын
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.
@hexadecimals10933 жыл бұрын
how do i do that
@roganjosh62203 жыл бұрын
@@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)
@hexadecimals10933 жыл бұрын
@@roganjosh6220OMG dude you ARE a legend. Thank you man!
@nielswillems9674 жыл бұрын
I don't know if anyone is still watching these, but my player stops moving after the interaction, any idea why?
@russellzeeryp90673 жыл бұрын
Same issue. If you figured it out I'd love to hear what you found.
@luislodosm7 жыл бұрын
Great pace of the tutorial.
@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"
@KreizLandGames7 жыл бұрын
All Your lessons are really helpfull even if I live in Russia !!)) Thanks!!
@2年早く夢を得た世界線の4 жыл бұрын
live Japan,too!
@Gamer-ne2vr4 жыл бұрын
When I focus on an object, it focuses but does not follow, any ideas?
@allenmasikati44213 жыл бұрын
Any replies or ideas to this? Same problem here.
@GolfBusters4 жыл бұрын
Question on why he uses Time.deltaTime * 5 for the slerp function. Time.deltaTime does not add upon itself correct? So, if you had enough fps couldn't Time.deltaTime * 5 never equal 1 and never make the full rotation?
@elomoim92012 жыл бұрын
i wrote good code and sphere not working how fix it???
@itzplaymind55517 жыл бұрын
I waited so long for this but it was worth it ;D
@clopes875 жыл бұрын
@5:32 why do we set the argument of FollowTarget to newFocus instead of the variable focus that we declared right above it?
@RichardCheese-go2rh Жыл бұрын
Still works for me so far thanks
@adamj19477 жыл бұрын
my Interactable interactable = hit.collider.GetComponent(); is returning null, however I have attached the interactable script to the sphere object. hit.collider is not null but the GetComponent return is.. any suggestions? Thanks
@drudan89577 жыл бұрын
Did you find a way to fix it?
@cainalthea26047 жыл бұрын
Did yo ufind anyway to fix it? :D
@drudan89577 жыл бұрын
Certhuz A. Chleih Set the object to the ground layer.
@cainalthea26047 жыл бұрын
I tried that. ITs like my right mouse button cant actually hit the sphere for some reason, and therefor it returns null, which results in not showing up when I click on it . Thank you though !
@查理-k5s7 жыл бұрын
Thanks you, fix my problem
@Donkeydog4 жыл бұрын
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?
@alexius34114 жыл бұрын
I have the same problem
@shiva_mahto3 жыл бұрын
If anyone still facing the same issue, remove movementLayer from if statement in right mouse click section. Worked for me.
@tomianugames34817 жыл бұрын
I'm trying to make a new game and I want to convince my GF to help me with it. But, she will have to watch tutorials and stuff cuz she's Jon Snow in programming. Now, if she finds this channel, she will dump me and marry Brackeys. So I think I'll do the game on my own :(
@rohantech84067 жыл бұрын
ToMiAn UGames Ha Ha Ha
@magnusm47 жыл бұрын
Who's John Snow? I don't get it
@cmsrepairs68377 жыл бұрын
hes a very good programmer
@xvishal7 жыл бұрын
Game of Thrones reference, meant to be Jon Snow.
@tomianugames34817 жыл бұрын
Hmm, yup, meant to be Jon. thanks for the correction, I've edited the comment.
@HumanitiesFunda6 жыл бұрын
You are just awsome.recently i am working on a cool open world game project . i have learnt a lot from you
@GeroTroXx7 жыл бұрын
Why don't you use colliders(as triggers) with their methods OnTriggerEnter, OnTriggerExit for interactables?
@MYTHICALLY3D4 жыл бұрын
:D exactly what i used to do lol
@Chokwik4 жыл бұрын
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
@Chang0d3 жыл бұрын
delete movement mask from the other one
@WreckedRevival7 жыл бұрын
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;}
@johnland83726 жыл бұрын
Dude do you ever slow down a bit. cause most of the time you always skip to the next part right before i was about to hit pause. Then i get lost and confused.
@diegocamacho2226 жыл бұрын
There is this amazing tool called "space key", when you press it the video automatically pauses where you need it to.
@jam546 жыл бұрын
@@diegocamacho222 lol 😂😂
@Change-jy1rl6 жыл бұрын
you can slow the video a bit go to setting and change Speed if you like really need that
@breakfastboi33446 жыл бұрын
slow down the vid
@AY-AY-RON.7 жыл бұрын
Hi, I seem to have run into a problem during the 13:45 mark of this video when changing the "transform" to "interactionTransform". I changed all of the ones he did in the video, then when I went back into Unity I seem an error pop up straight away before selecting the sphere saying; "Assets/Scripts/PlayerMotor.cs(34,28): error CS1061: Type `Interactable' does not contain a definition for `interactionTransform' and no extension method `interactionTransform' of type `Interactable' could be found. Are you missing an assembly reference?" Also when I selected the sphere there was no "Interaction Transform" to drag "Transform" into on my Interactable script. Here is the script it seems to be having trouble with: using UnityEngine; using UnityEngine.AI; [RequireComponent(typeof(NavMeshAgent))] public class PlayerMotor : MonoBehaviour { Transform target; NavMeshAgent agent; // Use this for initialization void Start () { agent = GetComponent(); } void Update() { if (target != null) { agent.SetDestination(target.position); FaceTarget(); } } public void MoveToPoint (Vector3 point) { agent.SetDestination(point); } public void FollowTarget (Interactable newTarget) { agent.stoppingDistance = newTarget.radius * .8f; agent.updateRotation = false; target = newTarget.interactionTransform; } public void StopFollowingTarget () { agent.stoppingDistance = 0f; agent.updateRotation = true; target = null; } void FaceTarget () { Vector3 direction = (target.position - transform.position).normalized; Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0f, direction.z)); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 5f); } } I double clicked on the error and it highlighted this particular line: target = newTarget.interactionTransform; Would appreciate it if someone could help me out with this problem. Cheers.
@temporaryaccount63255 жыл бұрын
Fruity Lexia Hi, I know your comment is a year old, but hopefully you can still find it use full. I looked over your script and it looks fine. Be sire to double check all the spelling. From the script to the sphere. I compared yours to mine and it looks the same.
@subucni225 жыл бұрын
Not sure if it will help anyone now but don't forget to add the Intractable Script to the Sphere. :)
@eugenepaul49524 жыл бұрын
For those who is right clicking on the object and nothing happens, try putting the right click method above the left click method
@froscity76625 жыл бұрын
I took all the code out to do with focusing because I'm just making a first person game and want to interact with a button but when I click on it it doesn't do anything. I'm trying to get it just to change the 'hasInteracted' variable in the interactable script but nothing happens. even put a debug message to display and that doesnt read as well i think its not recognising that the ray's hit an object with the script attached. any ideas?
@Kulbaru4 жыл бұрын
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-th8nx4cp7w4 жыл бұрын
Could it possibly be that your clicking on your players collider
@potatokinggaming35327 жыл бұрын
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); } }
@potatokinggaming35327 жыл бұрын
did you make it a public
@potatokinggaming35327 жыл бұрын
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); }
@EmanuelLopesS27 жыл бұрын
your public class, you need to change this name to your script name. you have NewBehaviourScript, change this
@punchdarkwing15916 жыл бұрын
The issue is it's 3f; not just 3;
@margaritabotero27877 жыл бұрын
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.]
@nicholasflint94804 жыл бұрын
Omfg you saved my life (and my computer), I've been stuck on this for hours, thank you!
@geameliai45004 жыл бұрын
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.
@rafirafchaines83167 жыл бұрын
Guys!I've just found that Interactable objects need to be on Ground layer!
@yego2116 жыл бұрын
Or you can remove the movementmask variable on your "if" argument since that is the one trapping the layermask.
@moonlightshadowpony5 жыл бұрын
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.
@chenariana34825 жыл бұрын
But it still wont stop when the player reach the edge of the radius of the interactable object..
@SamNBCA7 жыл бұрын
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.
@mikedupree26907 жыл бұрын
Same issue. If you comment that line out you no longer interact with the Object.. Curious what I did wrong
@SamNBCA7 жыл бұрын
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.
@skarrlive16167 жыл бұрын
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)
@chicc28264 жыл бұрын
yay! we made it through!
@mehmetizmirli90677 жыл бұрын
Please keep doing it. This is exactly whar i need :o :D Edit: Specially animating part.
@bernardb23486 жыл бұрын
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
@jakespencer19935 жыл бұрын
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_kotsu5 жыл бұрын
I have the same issue. Pretty frustrating.
@maximusthegreatest6 жыл бұрын
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?
@committedcoder33527 жыл бұрын
hi, can't wait to watch.
@committedcoder33527 жыл бұрын
btw, you interupted me watching a vid on nuka cola, but this is way better so dont feel bad
@tombecker11974 жыл бұрын
Assets\scripts\PlayerClick.cs(24,27): error CS1061: 'fallowplayer' does not contain a definition for 'ScreenPointToRay' and no accessible extension method 'ScreenPointToRay' accepting a first argument of type 'fallowplayer' could be found (are you missing a using directive or an assembly reference?)
@immortalhamster16454 жыл бұрын
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.
@adrianc50744 жыл бұрын
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.
@clunkerz39534 жыл бұрын
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!
@clunkerz39534 жыл бұрын
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.
@UsernameNULL7556 жыл бұрын
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.
@sgyffysgyffy47367 жыл бұрын
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.
@kugelrilli48434 жыл бұрын
i cant add the interactable script to the interactable the error says "Cant add script behaviour AssemblyInfo.cs. The script needs to derive from MonoBehaviour!" pls help
@FreeLeaks4 жыл бұрын
Make sure at the very top the 'public class *a name here* : MonoBehaviour{' is set to 'public class *AssemblyInfo* : MonoBehaviour{'
@QDurlstonP7 жыл бұрын
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!
@ChumperDumper7 жыл бұрын
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
@qwerty818087 жыл бұрын
Running it on a separate thread would, by definition, make it asynchronous.
@QDurlstonP7 жыл бұрын
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!
@willygamedev81447 жыл бұрын
At 8:16. Is it possible to user Euler angles instead of Quaternion.Lookrotation? (line 52) Quaternion lookRotation = Quaternion.Euler(new Vector3(direction.x, 0f, direction.z)); (line 53) transform.rotation = Quaternion.Slerp(transform.rotation, lookrotation, Time.deltaTime * 5f);
@fullmetalairsoft8586 Жыл бұрын
Getting an error with motor "Assets\Scripts\Movement.cs(12,12): error CS0246: The type or namespace name 'Motor' could not be found (are you missing a using directive or an assembly reference?"
@rodriguezgino70447 жыл бұрын
On the rotation part, my game got kinda weird. 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 interactable with right-click. Any help would be greatly appreciated.
@rodriguezgino70447 жыл бұрын
Never mind my request, hahaha. I completely forgot to add FaceTarget(); to the void Update() section.
@YourFutureCoach6 жыл бұрын
The problem is he went over that bit so fast that is very easy to miss. I missed it too.
@aidendawes35607 жыл бұрын
Hi Brakeys, your tutorials are awesome, I learn so much!!! Please can you do a save system tutorial?
@tylerguitar756 жыл бұрын
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.