IMPORTANT NOTE: unfortunately, the video does not show the script being added to the bird, so the coding does not really affect the game. Took me forever to figure it out, since I am new at this. Simply drag the script onto the component list and things will just start to work. In the video, the "Script" component just appears there @40:58. This is an EXCELLENT tutorial otherwise :).
I can't add my script to the bird object? and all the code inside the script isn't color coded? can you help? when I try apply my script to the object it comes up with an error saying 'Cannot add script component 'Bird' Make sure that there are no compile errors and that the class name and file name match' . I've named the class name and the object name the same too.
okay, so I've now added the script component to the object. but the code isn't working? it's still not color coded, here it is: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bird : MonoBehaviour { // Start is called before the first frame update void Start() { GetComponent().isKinematic = true; } void OnMouseDown() { GetComponent().color = Color.red; } void OnMouseUp() { GetComponent().color = Color.white; } void OnMouseDrag() { //Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); } // Update is called once per frame void Update() { } }
@@tomcartwright3160 I believe you might be having issues getting visual studio recognize Unity and vice-verse. There is some stuff you have to do to set up visual studio with Unity. Have you done it?
This is awesome! Very informative and what a great feeling it is to have an actual game after only a few hours! Learned a lot and had fun doing it too! Thank you
To make the bird change colour: 1> Drag the Bird.cs script onto the Inspector panel 2> In the Rigidbody 2D component (In the Inspector panel), make sure 'Simulated' is checked After pressing play, the bird should now change colour on mouse down *Took me a while to figure that one out, especially the 'Simulated' check box grr
That was pretty awesome! I've been following a bunch of tutorials but yours was very clear and informative. It wasn't bogged down with too much fluff and it wasn't too light on the details either.
If you bird moves to the middle and won't move at 51:23 then you may have had the same problem as me. I think the default camera settings for a 2d application are different on newer versions of unity. I fixed this by clicking the main camera in the scene editor, then changing the 'Projection' setting from perspective to orthographic.
I'm stuck at 57:22 and don't know what I'm doing wrong :/ When i enter : Vector2 direction = _startPosition - currentPosition; I get an error saying Compiler Error CS0019 Operator 'operator' cannot be applied to operands of type 'type' and 'type' I kind of want to give up and come back when I have more coding knowledge.
Adding the "bird" component to the bird fixed my issue. at 38:38 the "Bird component" wasn't in his inspector, but at 41:04 (the next time you see the inspector) the component is magically there. I hope he edits the video to make sure that newbies like me don't miss that part in the future.
For those who got stuck in the OnMouseDown that are not turning the bird red: There are two missing things on the tutorial (so far, i´m doing it too :) ): 1) He attach the script as a component to the bird. You can do this by hold click on the Bird script on the assets tab and dragging to the components of the bird on the right. 2) He return the Simulated variable of RigidBody 2D back to true. Click detection will not work without it.
You manage to explain everything really clearly without taking ages. And unlike many other tutorials you even include things like basic navigation. I am not a complete beginner, but there are a lot of little things that always took me a while to do while you explained how to do them easily and properly. I'm only 35 minutes into the tutorial, but I have been doing many things by myself first to see if I can figure out how to do it, and then I watch how you do it in a different and better way. I wish I had this tutorial when I was just starting out. I honestly think that this tutorial is a must for everyone who is starting out. There is just one thing that is just not acceptable. You use the dark theme for unity, which is really good. But at the same time you use the light theme for Visual Studio. That is just not acceptable! xD
@Tokey Do you miss a "using" at the top? It may also help to restart Unity if you haven't already tried this. These are the things I can think of right now. Hopefully it helps
What a surprise!I started with the same tutorial back then when it was published.Now I have a game on the google play store and participated in a gameJam.Thank you jason.I ll share this with my friends :)
BUG REPORT: Guess it's not really a bug, but needs some sort of variable when resetting. This happens when the BIRD COLLIDES with more than one crate and/or the ground and therefore makes multiple COROUTINE calls. (If you add a counter to each call to the coroutine you can see that sometimes up to 9 calls are made to ResetAfterDelay()) Subsequently, if you launch the BIRD before all the coroutines finish, the bird is SNAPPED back to pre-launch. This can be seen in the video @ 2:30:50
when i try to use the box snapping effect it doesnt let me place it on the ground flat at all, its either just floating or on top of the floor, no matter what i do this doesnt change... i have expanded the area in more ways than one gone back to original...everything and yet the snapping effect doesnt "sync" properly... im starting to think that unity isnt very clear cut of a program, seems very sloppy on how it does things... like example why have a massive grid that your working on if you cant get things to follow it by the actual squares itself (that would make things tessellate properly and also be neater)...
For all those, bird's image hiding in the background try using the "order in layer" in inspector tab and make it's value to 1. edit: you are great! solution is already there in the video!
we can do Vector2 instead of Vector3 in mouse drag: private void OnMouseDrag() { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = mousePos; }
I was going to ask this too. I was wondering why it would need to be Vector3 if we were then effectively having to handle the Z from -10. Many ways to "skin the cat" I guess. Such a great tutorial..
This video is about 2 hours long but I spent 10 hours on it just so I learned EVERYTHING that was going on. Thank you so much great video and clear to understand :)
You'll have no skills if you don't go out and seek them. Same goes for many things in life. People aren't just naturally good at everything, they work for it.
If you code and drop your script in the component list of Red Bird then it will work but for those who can not make this work like me, just change the body type to kinematic in Rigidbody 2D of component list of Red Bird
for some reason the first animation that we learn (when the bird flaps its wings) doesnt make the bird flap its wings, for me the bird flashes on and off screen
@@contempoarycode5710 Thanks for the info, but I had to lower the order to -1 to see it before the animation Copy/Paste then after I had to add to it put it at 2 to see it.
If anyone has trouble with the grid snapping not allowing your to line up your crates with the ground, then go to Edit -> Grid Settings and change the size to 0.5. This actually makes the grid look bigger, but in reality, it's smaller.
FYI for anybody confused about the Cinemachine part around 2:26:08, Cinemachine will show up in GameObject after it is installed/activated. Cinemachine used to show up in the toolbar like this video. I spent 10 mins on this, found this info in the description box. 😂
quick notice here for people who have this problem : " when I added the background into the scene it just overlays the bird. The bird wouldnt show as the background was covering it" what I did to solve it : On the right side of the screen when you click on the bird, there is a text that says "Sprite Renderer" that has next to it a check box. in the sprite renderer box there is a list called "Additional Settings". under that list is 2 things you can modify, one is "Sorting Layer" and the other is "Order in Layer" . the one that you want is "Order in Layer", in the box next to that make sure (while the bird is the chosen object) that the value is set to "1" and let the background's "Order in layer" value be set to 0. that way you can stop the bird from being overlaid by the background. hope this helps . edit : ok for those who continued watching you will realize he addresses the problem in the next segment of the video following the part that the problem occurs in, so you can ignore this comment and follow his method lol
Thank you, Jason. That's an excellent tutorial and helped me to put things into a better perspective after going through the basics in one of Unity 2D books. If I may make a suggestion, I'd suggest to switch Visual Studio to a dark team as it is easier on the eyes. Especially when there are a lot of switching between the dark Unity window and light VS window.
You are an amazing teacher, this single tutorial alone I learned a lot now I am interested in learning more. Going to dig more tutorials from your channel. Great material. Thanks a lot Jason!
Absolutely cracking tutorial, so nice to watch someone who is articulate, knows the subject matter and can relate the materials without constantly repeating expletives. A punchy to the point tutorial, which also teaches a great amount of detail.
My first day using Unity I'll come back again to see how much i improved Edit after two months: whaat just two months? that was faster than i thought! anyway i already made a game for a gameJam called miniJam in 3 days and it was my first game, i guess within two months i learned sooo much more than i thought i would and i am thinking to shift to robot engineering rather than making games.
I have watched the old tutorial before and honestly I think it's great. I'm relatively young so I won't be making a game public any time soon but I am very interested in coding and especially game development. In the future I hope I'll have enough experience and talent to make a full 3d game with unity and blender. And to anyone starting out(like me) don't worry if you don't understand or if it seems overwhelming, because it is. It takes years for someone to make a good quality game so don't be worried if it takes a long time.
@antun nutna Yeah I noticed when I did the second part with the OnMouseDown that it didn't work and I zoomed in the video if there were something missing. Thanks for the heads up!
This is the best tutorial I’ve ever followed on RU-vid! I’m new to game dev - but work as a web developer so I’ve seen a lot of similar content but this has been a stand out! A well thought out and well delivered tutorial. Thanks for putting in the time and effort!!!
Normally I don’t want such in-depth tutorials because I’ll be looking for something specific. BUT I’m 100% beginner to game development so I’m SOOOO appreciative for all this detail in your tutorial. I think this is very beginner-friendly.
If you are tired of removing 'private' at the start of functions, go to tools>options>Options for Unity>General>Code edition>Unity messages scope and set it to default Edit: Do this in Visual studio not unity
OK...when I get to the create C# script & input the first line of code you suggest "GetComponent().isKinematic = True;" my bird still falls. Update: I looked at your video a little more closely & noticed that you had Scripts enabled, while mine was not. I had to go to "Add Component" & add Scripts & then select the "Bird" script, and it finally worked. (Another thing you should show in your video for newbies.)
Thank you so much for this amazing tutorial! I legit have not stopped thinking about it all day :) Legit even making that bird turn red when you click on it has brought a huge smile to my face
Jason, Happy New year! Awesome Tutorial! For users on Unity 2018.4 and up after they import the Cinemachine, the Cinemachine menu option moved under the GameObject menu. There you can add the 2D Camera.
I have solved this: > The answer is that I typed onEnable instead of OnEnable when I initialised _monsters That error didn't show up, but caused the subsequent error to occur as there was nothing in _monsters It took me a few hours to spot, but is was great to get it working in the end.
i keep on asking questions and then I got back to unity and do something and then I immediately find the answer of my question and then delete the comment
I'm using VS code instead of VS community because I was learning C# before I found this video, I would feel better using it as well because I have used it for both C and C#, but whenever I try to write the code it will not auto complete like it would in the video... Can I do something to fix it or do I have to use VS community?
@The Potate Master Thanks a lot sir , i also thought that could be the mistake because in The video in the component panel thing the script was added i also thought that could be the mistake but didnt know how to add the script THANKS A LOT SIR !!!!
I had your same issue and followed the same advice. When it didn't work I learned a very important lessor. I had messed with the Simulated checkbox to see the effects for myself and left it off. Note: An object that is not Simulated apparently cannot be clicked on. Figured that might help anyone else who has that issue and did the previous already.
jesus for those stuck on the same issue i am which btw is a huge mistake to miss in the video.... you have to drag the script onto the red bird hierarchy AND THEN YOU HAVE TO SAVE IN UNITY ASWELL!!!
suddenly when I start the game after adding the monster the boxes fall to the ground and rotate so the monster and I can't move the bird, anyone knows what's the problem?
Hey can someone please help me at 29:57 like when his bird flaps my bird flickers on and off please help I just started today and have no idea what I should do to fix it thank you!
i know i am 2 years late but i get a NullReferenceException error at the line after the bool monsterareallldead and idk how to fix it bc i am new at this so if you see this can you help me ?
Hey when i do all the coding I've checked it multiple times the spelling is all right and there's no errors my bird dosen't seem to turn red then white. I am on visual studio community 2019 btw but on unity version 2020 does that make a difference
It does not matter which version of visual studio you are (2017 or 2019) as long it is setup correctly in unity he shows where to do it (I Believe). What I had is that I eighter missed him telling to add the Bird script to the Red Bird or he did not mentioned it all. I didn't bother to go back to check which it is. This might be the problem you have.
@@ahtdejonge He forgot to talk about adding the bird script and only mentions it during another step. That was indeed the issue (at least for me). I figured it out by reading some other people's comments shortly after I had the problem, but forgot to say it here.
for those who are having trouble with the script not working, dont worry, he just didnt mentioned how to link the scripts with the object, just drag the script to the component section
The bird sets the three second timer every time it collides, meaning that sometimes when you pull back on it after it resets the first time it will "lag" and reset a second time mid-air. Does anyone know how to fix this?
@@Yaybuttons898 I began the timer on “OnMouseUp” (when you launch the bird) instead of on every collision so that it only registers one reset instead of multiple
@@IGNACY-fp8zo Since making that change, it now causes my bird to reset mid air... I occasionally have a glitch whereby when i pull back on the bird, it dops off and I have to re start pulling back on the bird
@@PeterJohnson76 That’s really strange. Are you sure you have the timer in the proper spot? Play around with that. An important skill in programming is being able to troubleshoot like that.
are we opening the visual studio in blue or blue (extra contrast) ??? come on buddy you are leaving way too many steps out and its really frustrating and confusing :S
did anyone else have a problem with the code for the bird not falling by default? i wrote the code and it is not stimulated but the bird still falls. help pls
Useful thing for the issue described around 1:19:25 - Another way to make double-sure you don't accidentally click out of the thing you've selected in the inspector is to lock it! At the top right, to the right of the tab with the word "Inspector" on it, there's a little padlock icon. Clicking that will lock the inspector into looking at the thing(s) you have selected. This can have its own mild issue where you have to remember to UNlock it afterward, but it's still useful to know about, especially if you're doing the kind of thing described here where you're selecting several elements in the scene by hand. That's a situation where being sure you won't lose those selections to a misclick is totally worth it.
Seems like this unity engine needs a method for say 2dObjectDrag to grab the x.y coordinates and apply them to an object. That drag method is clunky and not conclusive to a new user learning experience. Great job BTW, you have far more patience than I will ever have. ;)
I have my code worked out just like his, but for some reason the disappearing and respawning elements aren't working. My bird will hit the monster, boxes, ground, etc, but it won't trigger the disappear and reappear functions. I've tried everything, including reloading both unity, visual studio and even restarting my computer. I have no idea what's wrong or where to even proceed to attempt to fix it, and the console isn't flagging anything either. Below is my code for my bird, but the monster isn't dissapearing when hit either. using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bird : MonoBehaviour { [SerializeField] float _launchForce = 500; Vector2 _startPosition; Rigidbody2D _rigidbody2D; SpriteRenderer _spriteRenderer; void Awake() { _rigidbody2D = GetComponent(); _spriteRenderer = GetComponent(); } //this was the issue I had with Remove in the RPG, Start_position //Generated this with the little lightbulb, and "generate field" //This is needed since the field is never referenced. //we didn't need the private field, so i removed it. void Start() { _startPosition = _rigidbody2D.position; _rigidbody2D.isKinematic = true; } void OnMouseDown() { _spriteRenderer.color = Color.red; } void OnMouseUp() { Vector2 currentPosition = _rigidbody2D.position; Vector2 direction = _startPosition - currentPosition; direction.Normalize(); _rigidbody2D.isKinematic = false; _rigidbody2D.AddForce(direction * _launchForce); _spriteRenderer.color = Color.white; } void OnMouseDrag() { Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = new Vector3(mousePosition.x,mousePosition.y, transform.position.z); } void Update() { } void OnCollisionEnter2d(Collision2D collision) { StartCoroutine(ResetAfterDelay()); } IEnumerator ResetAfterDelay() { yield return new WaitForSeconds(3); _rigidbody2D.position = _startPosition; _rigidbody2D.isKinematic = true; _rigidbody2D.velocity = Vector2.zero; } }
The solution is that I needed to install the Unity autocomplete, because for some reason despite typing it out word-for-word, I believe unity wasn't accounting for this as a function, and when I had it autocomplete, it worked.
You Sir are a legend!! this is by far the best tutorial on youtube I saw. your detailed and clear instructions are so easy to follow, even at 1.5x :) Thank you!!
Apart from a couple of minor things others have picked up on, Jason's video tutorial is the best I have watched here at RU-vid so far. He has a very confident, neat and well explained approach to his teaching. His videos appear to be well planned out beforehand and he doesn't run into problems and start scratching his head halfway through wondering what he has done wrong like others I have seen. Very slick, very professional approach, Great stuff Jason, I shall be watching more! Thanks very much.
If you messed up this might help - Add the bird script to the “Red Bird” sprite. Make sure Simulated is checked in the Red Bird sprite. If your bird falls into the ground at the start try switching the Body Type to Kinematic in RigidBody2D
Can you help? Why using System.Collections; using System.Collections.Generic; using UnityEngine; public class BeekRedOpen1 : MonoBehaviour { // Start is called before the first frame update void Start() { GetComponent().isKinematic = true; } // Update is called once per frame void Update() { } } is not working?
Hello! Everything works fine, but for me, when I added the background into the scene it just overlays the bird. The bird wouldnt show as the background was covering it. Is there any way that we can make the bird go on top of the background?
same problem I had, here is how I solved it : On the right side of the screen when you click on the bird, there is a text that says "Sprite Renderer" that has next to it a check box. in the sprite renderer box there is a list called "Additional Settings". under that list is 2 things you can modify, one is "Sorting Layer" and the other is "Order in Layer" . the one that you want is "Order in Layer", in the box next to that make sure (while the bird is the chosen object) that the value is set to "1" and let the background's "Order in layer" value be set to 0. that way you can stop the bird from being overlaid by the background. hope this helps .
I would appreciate if you would create some more intermediate/advanced game tutorial, since there are so many tutorials for beginners and twice less for more advanced guys (:
Everything else worked fine until I placed the background because the background was covering the bird and I couldn’t see it and I tried everything even making a whole new project so I don’t know can someone help me