INTERACTION - Making an RPG in Unity (E02)

  Рет қаралды 510,516

Brackeys

Brackeys

Күн бұрын

Пікірлер: 594
@joshdecker3334
@joshdecker3334 3 жыл бұрын
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 жыл бұрын
You might be running a different version of Unity, or a different version of C#
@dibaterman
@dibaterman 3 жыл бұрын
I feel more comfortable playing Russian roulette, at least I've never failed at that.
@obsidianflight8065
@obsidianflight8065 3 жыл бұрын
@@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???
@photonman54
@photonman54 7 жыл бұрын
the .Slerp function allows the Quaternion to eat hot soup with out burning its mouth.
@calvinz9126
@calvinz9126 4 жыл бұрын
Y E S
@immortalhamster1645
@immortalhamster1645 4 жыл бұрын
Lmfaoooo
@Sakdos
@Sakdos 3 жыл бұрын
@AstroFahl Parent may have no mouth
@athakmaurya164
@athakmaurya164 2 жыл бұрын
wtf
@elomoim9201
@elomoim9201 2 жыл бұрын
i wrote good code and sphere not working how fix it???
@thebluereason
@thebluereason 4 жыл бұрын
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???
@ArnoldsKtm
@ArnoldsKtm 7 жыл бұрын
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.
@ResoCoder
@ResoCoder 7 жыл бұрын
Whoah! The quality of this tutorial is top notch. Thanks Brackeys!
@Coreycoreyomg
@Coreycoreyomg 6 жыл бұрын
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???
@Giorgi.Japiashvili
@Giorgi.Japiashvili 6 жыл бұрын
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???
@ilias_from_ilios
@ilias_from_ilios 4 жыл бұрын
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!
@Pentasoniczound
@Pentasoniczound 6 жыл бұрын
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 жыл бұрын
It's the final boss of coding.
@km_youtube23
@km_youtube23 7 жыл бұрын
For anybody having a 'null' Interactable error when clicking the sphere, try removing the LayerMask from the Physics.Raycast parameters.
@byebyegiomar
@byebyegiomar 6 жыл бұрын
thx bro
@chris-iy9yt
@chris-iy9yt 6 жыл бұрын
Thanks alot!
@alihaydargubatov2790
@alihaydargubatov2790 6 жыл бұрын
Mine problem was however calling OnDefocused twice inside SetFocus
@wildlifegmd2422
@wildlifegmd2422 6 жыл бұрын
Thank, You. saved me alot of time here mate
@abrahammartinez6894
@abrahammartinez6894 5 жыл бұрын
Most underrated comment
@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!
@LC-xq7zi
@LC-xq7zi 4 жыл бұрын
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 жыл бұрын
As a beginner, this was a tough one, a lot of just rewriting, but it all came together in the end. Thanks!
@alexanderelert2877
@alexanderelert2877 7 жыл бұрын
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???
@andreasrips4857
@andreasrips4857 5 жыл бұрын
man makes top tier things look so simple im scared for this man's power tbh
@TheTeaTycoon
@TheTeaTycoon 7 жыл бұрын
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.
@bloaa
@bloaa 4 жыл бұрын
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 жыл бұрын
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???
@gitwilma4286
@gitwilma4286 6 жыл бұрын
I had some coding projects due last minute. Thanks, Brackeys, You guys make coding so easy!
@XURlMA
@XURlMA 3 жыл бұрын
I love this man from the bottom of my heart
@Saleca
@Saleca 4 жыл бұрын
great series, you are definitely my go to for learning unity stuff!! practical, comprehensive and pleasant, thanks!
@NotNazuh
@NotNazuh 3 жыл бұрын
I've been looking for this for so long, thank you so much!
@bobtgg
@bobtgg 7 жыл бұрын
Cant wait till the next episode...Great work as always
@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
@KaletheQuick
@KaletheQuick 7 жыл бұрын
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 жыл бұрын
@@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.
@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 жыл бұрын
Np haha checked your tutorial and you also have a beautiful voice and good content to teach. So, +1 subscriber!
@DannyMakesStuff
@DannyMakesStuff 7 жыл бұрын
Loveless Tsukashi cool thanks! Maybe I should start show myself like brackeys 😂
@phattrinhtan4562
@phattrinhtan4562 3 жыл бұрын
still the best and shortest tutorial :D
@GausRothTutorials
@GausRothTutorials 4 жыл бұрын
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.
@dylloop
@dylloop 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 жыл бұрын
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 6 жыл бұрын
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
@fonsly5077
@fonsly5077 4 жыл бұрын
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.
@darkdoom907
@darkdoom907 2 жыл бұрын
9:55, check if player is in range
@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 жыл бұрын
Setting it to false makes it easier to understand for others! And it doesn't muddle up the code that much..
@dan_kotsu
@dan_kotsu 5 жыл бұрын
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?
@jakespencer1993
@jakespencer1993 5 жыл бұрын
Same issue
@kenichibeveridge8718
@kenichibeveridge8718 5 жыл бұрын
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.
@chenariana3482
@chenariana3482 5 жыл бұрын
Same, have no idea why mine is not working
@resonatebob4495
@resonatebob4495 7 жыл бұрын
I've been waiting for something like this, thanks!
@Ninja1k1
@Ninja1k1 7 жыл бұрын
never clicked notification so fast
@hamahed1778
@hamahed1778 4 жыл бұрын
likes go brrr
@matthewkeron1448
@matthewkeron1448 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
@danisob3633
@danisob3633 7 жыл бұрын
YAY i was waiting 7 years for this
@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 3 жыл бұрын
Thank you, I was looking for this!
@carlsagan9808
@carlsagan9808 7 жыл бұрын
Bookmark 6:28, also thanks, Brackeys, for the good video
@amilismurfs
@amilismurfs 7 жыл бұрын
I really love the clicking and typing sound :)
@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.
@logoteam4998
@logoteam4998 4 жыл бұрын
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???
@cptant7610
@cptant7610 7 жыл бұрын
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 жыл бұрын
@@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.
@esotericdamian5029
@esotericdamian5029 3 жыл бұрын
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?
@rylanhrasko7053
@rylanhrasko7053 6 жыл бұрын
k so I got a problem, my person wont interact with the object, no errors are popping up, any suggestions?
@jamesiagary1388
@jamesiagary1388 5 жыл бұрын
Rylan Hrasko then the next game you will love them you won’t get bored and they can not beat you
@khanyakubheka1020
@khanyakubheka1020 4 жыл бұрын
right click
@funnyin4157
@funnyin4157 3 жыл бұрын
Thanks for making this series now I can make my own RPG game!
@chenariana3482
@chenariana3482 5 жыл бұрын
agent.StopingDistance is not working.... My player wont stop when he reach the radius of the enemy... Any ideas?
@andreutormos7210
@andreutormos7210 7 жыл бұрын
Ep 2!!! Thanks Brackeys :D
@Filmedbycjj
@Filmedbycjj 6 жыл бұрын
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 5 жыл бұрын
This helped. I was losing my mind. Thanks :)
@Exori
@Exori 4 жыл бұрын
Thanks
@Chang0d
@Chang0d 3 жыл бұрын
delete movement Mask
@williamc8395
@williamc8395 6 жыл бұрын
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 жыл бұрын
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 6 жыл бұрын
@@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 6 жыл бұрын
Fikri Lazzuardi I was so stuck until I read this. Thanks
@kevinwang7601
@kevinwang7601 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 7 жыл бұрын
It would be easier to find the reason of error if you could specify the line where the error is being generated.
@GzE1337
@GzE1337 7 жыл бұрын
u missed the part on 14:10 where he tells you to use the own transform object from the circle as his interaction transform
@punchdarkwing1591
@punchdarkwing1591 6 жыл бұрын
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 жыл бұрын
I've got the same problem....anybody please help
@jaywilliams9721
@jaywilliams9721 4 жыл бұрын
Same, have you got a fix?
@aza1ization
@aza1ization 7 жыл бұрын
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
@arthos4551
@arthos4551 7 жыл бұрын
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.
@mahmoudshatnawi6122
@mahmoudshatnawi6122 7 жыл бұрын
All good programmers felt the same at some point. I can help you with something if you want
@ResoCoder
@ResoCoder 7 жыл бұрын
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!
@elofkarlsson6343
@elofkarlsson6343 7 жыл бұрын
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.
@gmfCoding
@gmfCoding 7 жыл бұрын
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.*
@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.
@SovakaKindred
@SovakaKindred 7 жыл бұрын
Question: Why did you not use 'Transform.LookAt' instead of creating your own version of it?
@tylerguitar75
@tylerguitar75 6 жыл бұрын
Transform.LookAt would snap the rotation. Doing it his way with slerp lets us do it smoothly at our specified speed
@roganjosh6220
@roganjosh6220 3 жыл бұрын
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 жыл бұрын
@@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!
@nielswillems967
@nielswillems967 4 жыл бұрын
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.
@luislodosm
@luislodosm 7 жыл бұрын
Great pace of the tutorial.
@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"
@KreizLandGames
@KreizLandGames 7 жыл бұрын
All Your lessons are really helpfull even if I live in Russia !!)) Thanks!!
@2年早く夢を得た世界線の
@2年早く夢を得た世界線の 4 жыл бұрын
live Japan,too!
@Gamer-ne2vr
@Gamer-ne2vr 4 жыл бұрын
When I focus on an object, it focuses but does not follow, any ideas?
@allenmasikati4421
@allenmasikati4421 3 жыл бұрын
Any replies or ideas to this? Same problem here.
@GolfBusters
@GolfBusters 4 жыл бұрын
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?
@elomoim9201
@elomoim9201 2 жыл бұрын
i wrote good code and sphere not working how fix it???
@itzplaymind5551
@itzplaymind5551 7 жыл бұрын
I waited so long for this but it was worth it ;D
@clopes87
@clopes87 5 жыл бұрын
@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
@RichardCheese-go2rh Жыл бұрын
Still works for me so far thanks
@adamj1947
@adamj1947 7 жыл бұрын
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
@drudan8957
@drudan8957 7 жыл бұрын
Did you find a way to fix it?
@cainalthea2604
@cainalthea2604 7 жыл бұрын
Did yo ufind anyway to fix it? :D
@drudan8957
@drudan8957 7 жыл бұрын
Certhuz A. Chleih Set the object to the ground layer.
@cainalthea2604
@cainalthea2604 7 жыл бұрын
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 !
@查理-k5s
@查理-k5s 7 жыл бұрын
Thanks you, fix my problem
@Donkeydog
@Donkeydog 4 жыл бұрын
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 жыл бұрын
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.
@tomianugames3481
@tomianugames3481 7 жыл бұрын
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 :(
@rohantech8406
@rohantech8406 7 жыл бұрын
ToMiAn UGames Ha Ha Ha
@magnusm4
@magnusm4 7 жыл бұрын
Who's John Snow? I don't get it
@cmsrepairs6837
@cmsrepairs6837 7 жыл бұрын
hes a very good programmer
@xvishal
@xvishal 7 жыл бұрын
Game of Thrones reference, meant to be Jon Snow.
@tomianugames3481
@tomianugames3481 7 жыл бұрын
Hmm, yup, meant to be Jon. thanks for the correction, I've edited the comment.
@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
@GeroTroXx
@GeroTroXx 7 жыл бұрын
Why don't you use colliders(as triggers) with their methods OnTriggerEnter, OnTriggerExit for interactables?
@MYTHICALLY3D
@MYTHICALLY3D 4 жыл бұрын
:D exactly what i used to do lol
@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
@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;}
@johnland8372
@johnland8372 6 жыл бұрын
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.
@diegocamacho222
@diegocamacho222 6 жыл бұрын
There is this amazing tool called "space key", when you press it the video automatically pauses where you need it to.
@jam54
@jam54 6 жыл бұрын
@@diegocamacho222 lol 😂😂
@Change-jy1rl
@Change-jy1rl 6 жыл бұрын
you can slow the video a bit go to setting and change Speed if you like really need that
@breakfastboi3344
@breakfastboi3344 6 жыл бұрын
slow down the vid
@AY-AY-RON.
@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.
@temporaryaccount6325
@temporaryaccount6325 5 жыл бұрын
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.
@subucni22
@subucni22 5 жыл бұрын
Not sure if it will help anyone now but don't forget to add the Intractable Script to the Sphere. :)
@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
@froscity7662
@froscity7662 5 жыл бұрын
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?
@Kulbaru
@Kulbaru 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
@potatokinggaming3532
@potatokinggaming3532 7 жыл бұрын
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 7 жыл бұрын
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;
@margaritabotero2787
@margaritabotero2787 7 жыл бұрын
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!
@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.
@rafirafchaines8316
@rafirafchaines8316 7 жыл бұрын
Guys!I've just found that Interactable objects need to be on Ground layer!
@yego211
@yego211 6 жыл бұрын
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 5 жыл бұрын
But it still wont stop when the player reach the edge of the radius of the interactable object..
@SamNBCA
@SamNBCA 7 жыл бұрын
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 жыл бұрын
Same issue. If you comment that line out you no longer interact with the Object.. Curious what I did wrong
@SamNBCA
@SamNBCA 7 жыл бұрын
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 жыл бұрын
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)
@chicc2826
@chicc2826 4 жыл бұрын
yay! we made it through!
@mehmetizmirli9067
@mehmetizmirli9067 7 жыл бұрын
Please keep doing it. This is exactly whar i need :o :D Edit: Specially animating part.
@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
@jakespencer1993
@jakespencer1993 5 жыл бұрын
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.
@maximusthegreatest
@maximusthegreatest 6 жыл бұрын
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?
@committedcoder3352
@committedcoder3352 7 жыл бұрын
hi, can't wait to watch.
@committedcoder3352
@committedcoder3352 7 жыл бұрын
btw, you interupted me watching a vid on nuka cola, but this is way better so dont feel bad
@tombecker1197
@tombecker1197 4 жыл бұрын
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?)
@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.
@adrianc5074
@adrianc5074 4 жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
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.
@UsernameNULL755
@UsernameNULL755 6 жыл бұрын
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.
@sgyffysgyffy4736
@sgyffysgyffy4736 7 жыл бұрын
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.
@kugelrilli4843
@kugelrilli4843 4 жыл бұрын
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
@FreeLeaks
@FreeLeaks 4 жыл бұрын
Make sure at the very top the 'public class *a name here* : MonoBehaviour{' is set to 'public class *AssemblyInfo* : MonoBehaviour{'
@QDurlstonP
@QDurlstonP 7 жыл бұрын
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!
@willygamedev8144
@willygamedev8144 7 жыл бұрын
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
@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?"
@rodriguezgino7044
@rodriguezgino7044 7 жыл бұрын
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.
@rodriguezgino7044
@rodriguezgino7044 7 жыл бұрын
Never mind my request, hahaha. I completely forgot to add FaceTarget(); to the void Update() section.
@YourFutureCoach
@YourFutureCoach 6 жыл бұрын
The problem is he went over that bit so fast that is very easy to miss. I missed it too.
@aidendawes3560
@aidendawes3560 7 жыл бұрын
Hi Brakeys, your tutorials are awesome, I learn so much!!! Please can you do a save system tutorial?
@tylerguitar75
@tylerguitar75 6 жыл бұрын
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!
ITEMS - Making an RPG in Unity (E04)
14:46
Brackeys
Рет қаралды 384 М.
every step to actually make your dream game (then sell it)
24:27
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
MOVEMENT - Making an RPG in Unity (E01)
17:11
Brackeys
Рет қаралды 1,2 МЛН
INTEGRATION 01 - Making an RPG in Unity (E03)
7:55
Sebastian Lague
Рет қаралды 347 М.
How to MAKE YOUR GAME LOOK GOOD!
13:02
Brackeys
Рет қаралды 603 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
Introduction to AUDIO in Unity
14:26
Brackeys
Рет қаралды 1 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 793 М.
СОЗДАЛ ИГРУ ИСПОЛЬЗУЯ ТОЛЬКО ChatGPT
6:01
Robert Sergeev
Рет қаралды 225 М.
How to make The Best First Person Camera in Unity
9:04
semikoder
Рет қаралды 28 М.
10 Minutes vs. 10 Years of Animation
19:29
Isto Inc.
Рет қаралды 1,5 МЛН
HOW TO PLAYTEST!
11:15
Brackeys
Рет қаралды 222 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН