If you want to change the launchForce according to mousePosition you can remove public from launcForce and write launchForce = Vector2.Distance(shotPoint.position, Camera.main.ScreenToWorldPoint(Input.mousePosition)); in the Update function
8:57 you dont need to do == with bool if statement like "if (bool == true)" you can just do "if (bool)" for true and "if (!bool)" for false edit* nice to have you back, haven't seen a vid from you in a while :)
@@rdev3720 of course its possible, i just hope i'm not late (even tho the question isnt directed towards me T - T) you cud achieve that effect using coroutines or you cud make ur own timers! Check this out - answers.unity.com/questions/1108438/how-to-instantiate-prefabs-at-certain-times.html
When calculating position of points it would be beneficial to reuse position of previous point, that way you will need to do less calculations overall. So, instead of creating a function that calculates position based on time, you factor in everything into the loop and reuse state between iterations.
Thanks for the video guys, appreciate it and it helped me a lot. However there are 2 issues I ran into. First, when the arrows gets stuck in an object, and for instance enemies run into them, they continue to take damage from collisions with the arrow. This I fixed by disabling the collider. Second, if you'd like the arrow to follow the game object it sticks to, parent it to the collided object. 2 lines of code fixed these issues for anyone else in the same situation: After applying damage, in the OnCollisionEnter2D method: gameObject.GetComponent().enabled = false;
// Arrow no longer collides with other objects after first collision transform.parent = collision.transform; // Arrow follows collided object Again, thanks and hope this helps someone else!
Is there any way to make line renderer length limit ? line renderer endPos follow mouse position but line length goes infinite want line length limited.
Yay my man noa is back. I really have fun at your udemy course. This 2D strategy game is literally awesome. You guys make the project to expansive project. Really worth to check out guys. Really thankful to noa and Liam for amazing course,and free tutorials!
Thanks so much, This helped a lot, I searched drastically for a tutorial for this and yours was by far the most effective and simplest. Quick Question: Is there a way to stop the dots from showing after they collide with a platform, so that you never see the dots beyond the platform that it hits?
Hello Blackthornprod, i love your videos and because of them will get into game dev. I wanted to ask is starting to learn unity at 13 years old late? Thanks again for inspiring me to get into game development
Yes, you’re too old. Most devs begin when they are younger than 5 years old. Just kidding, you will never be too old to learn anything. And it is never too late to learn anything. However, things can be easier or harder at different times.
in the Shoot method, you would multiply the velocity of the arrow by the distance between the mouse position and the bow position, and then clamp it between two numbers
hey men i have trouble using transfrom any gues? The type or namespace name 'Transfrom' could not be found (are you missing a using directive or an assembly reference?)
How would you make the line thing for an a.i? Id like to show the user where the enemy is aiming before it attacks. Any help would be appreciated love your work
Fun tutorial, has anyone gotten this to handle the fact if you are moving with arrow keys and pressing left faces the character left with the local scale .x to -1 ? If I face right it all works, if I turn left it is all off on the math, ideally the bow wouldn't even care what direction the player is facing but not sure how to make that happen sinced the Bow game object is a child of the parent.
Hey! Thanks for the tutorial. This is a super useful tutorial. I have an idea for a challenge. As you are very good at making games, how well can you make a game in scratch? It can just be a quick and easy challenge. Thanks for the tutorial!
This is almost exactly what I needed, how would I go about showing the proper trajectory if I want my bullet to bounce off of objects? Right now the line goes right through objects with colliders even though the bullet itself is bouncing off of them.
Hi Guys. Vector2 position =(Vector2)shotPoint.position + (direction.normalized * launchForce * t) + 0,5f * Physics2D.gravity * (t*t); the error says '+' , cannot be applied to 'Vector2' and 'int'. something like this. I used brackets but did not work. Any suggestion ?
So this vids 11months old but figure I’ll ask anyway. What would be a good way to code it so player input can affect velocity and therefore trajectory? Was thinking something like holding the key down longer, makes the shot faster/straighter.
Hey Noah and Liam I hope you guys see this because I need help. I am trying to do the Game Tiny Planets with your Tutorial but it isnt working when i am trying to do the play button. Do I have to create the button in the play image tab or in the Canvas because when i create the Button in the image tab it isnt working and when i create it in the Canvas it is working but the play button is HUGE
That was really awesome:)...Somehow can you pls give me piece of advice to make projectile collide .. it's actually overlapping objects.. Thanks in advance..
Yay our man noa I am really have fun in your strategy 2D course !Guys this strategy game is really fun and worth to buy. Literally amazing 😍.I bought topdown shooter too but I haven't done yet cause I literally have fun at 2D strategy game. Really really cool.Love u bro noa and Liam 🤩🤩
When setting the rotation, use rb.rotation instead of transform.rotation; this is guaranteed to be the actual position of the body. Transforms are not for the physics system; they're for everything else, like animations, etc.
Hi, interesting tutorial. If I wanted to move a 2D character according to the pointing direction of the mouse (without clicking) and moving the character only at the press of a button (for example W), how can this be done ? Have you already done a tutorial on this topic ?
u cud use MoveTo function or get the mouse position, as they did in this video, and use transform.translate or use the character's rigidbody and give it some velocity along the direction of (mousePosition - characterPosition) or something... it need not necessarily be as brief as i mentioned but is sure easy to understand
Did you figure it out? You would use something similar, find the angle. Find the distance between the mouse and character. Set your velocity, or add force as distance x movement speed in the direction
So I followed the steps but it's not creating any arrows. I can see them being created in the sample scene but not in the actual game. Any idea as to why?
Hey Blackthornprod, I just discovered you today and I'm loving your content. I don't know if it's a recent change but the Udemy courses seem to be $50 dollars instead of $10. Was this only a limited-time sale?
Hey dude! Unrelated to the vid but could you consider putting some of your games on the switch E- shop? They would be great for it, would bring in some extra money and the switch needs it rn. The e shop is full of trash. Idk how how converting it would work tho, I’m an animator not,a game dev.
Nintendo is shit to deal with if i am right. It needs some extra work to get games there and putting games on pc is 100times easier. But still yeah it is possible and would be cool
Vector2 currentPosition =(Vector2)transform.position + (transform.right * force * t) + 0.5f * Physics2D.gravity * (t*t); CS0034 Operator '+' is ambiguous on operands of type 'Vector2' and 'Vector3' where am i going wrong ?
lol is anyone else getting the "NullReferenceException: Object reference not set to an instance of an object Bow.Update () (at Assets/Bow.cs:18)" when they put in the code? pls help lol
I'm trying to make points work properly on my angry birds clone. Do you have any video guide suggestions that I can watch about this tip you just gave ?
Grear tutorial liam. However, u should show to cache most of the variables for better performans. I know this is a beginner tutorial but would be still good :) still a very good video 👍🏻💪🏻
Agreed! Especially when using camera.main, as that translates to a "FindObjectOfType()" if I recall correctly from one of the Unity Unite talks, which is really slow. Either create a reference in the script ([Serializefield] or public) and drag over the camera, OR at least in Start / Awake, call camera.main and store the reference for use in the script update. Camera.main use is mentioned in many tutorials and talks as a major performance issue so it is a good practice to get used to not using it in update / fixedupdate. Good job otherwise :)
If you want to change the launchForce according to mousePosition you can remove public from launcForce and write launchForce = Vector2.Distance(shotPoint.position, Camera.main.ScreenToWorldPoint(Input.mousePosition)); in the Update function
Nice tip!
8:57 you dont need to do == with bool if statement like "if (bool == true)" you can just do "if (bool)" for true and "if (!bool)" for false
edit* nice to have you back, haven't seen a vid from you in a while :)
Sometimes it helps to understand the code, even if it's redundant
wrong. code won't compile.
@@gamedevhq i hope u get that when he said 'bool' he was referring to that particular boolean identifier and not the keyword bool
Liam sounds alot like noa. It took me time to notice 😂
B A u are right man!
I know right? Liam should use a batman voice... lol. The switch was almost seamless.
well, they are brother after all!
They have the same accent, and similar ways of speaking, but Liams voice is higher.
There freaking brothers duh, lol but yes they do sound alike
Welcome back teacher.
Glad to be back !
blackthornprod is it possible to create a stationary enemy that shoots projectiles after 1 second if so how? Please respond soon.
@@rdev3720 of course its possible, i just hope i'm not late (even tho the question isnt directed towards me T - T)
you cud achieve that effect using coroutines or you cud make ur own timers! Check this out - answers.unity.com/questions/1108438/how-to-instantiate-prefabs-at-certain-times.html
There is almost no difference between noa and liam
Except their name
We are brothers after all :)
@@Blackthornprod omg thanks for the reply. Your channel is awesome! U r my inspiration
I've also found it ! hahahahaha
HOORAY! Thanks for this. I was one of people that requested it. You shall be rewarded by the Game Gods.
he stole code lol
Wow thank's for that !
glad to see Noa is still alive, as he hadn't uploaded for a almost 2 months 😂
You guys always make these tutorials so easy to understand. Thanks!
I barely understood any of this but seemed to work in the end. Cheers for the tutorial
You guys getting better by the time
When calculating position of points it would be beneficial to reuse position of previous point, that way you will need to do less calculations overall. So, instead of creating a function that calculates position based on time, you factor in everything into the loop and reuse state between iterations.
god level physics and game concepts!
Thanks for the video guys, appreciate it and it helped me a lot. However there are 2 issues I ran into. First, when the arrows gets stuck in an object, and for instance enemies run into them, they continue to take damage from collisions with the arrow. This I fixed by disabling the collider. Second, if you'd like the arrow to follow the game object it sticks to, parent it to the collided object.
2 lines of code fixed these issues for anyone else in the same situation:
After applying damage, in the OnCollisionEnter2D method:
gameObject.GetComponent().enabled = false;
// Arrow no longer collides with other
objects after first collision
transform.parent = collision.transform;
// Arrow follows collided object
Again, thanks and hope this helps someone else!
Thanks
@junglejim6674
how did you make it do dmg to enemys
I love you so much. I'm just 3 years late.
Finally! The master has return, and this is what i need from a long time for my game
I would love a tower defense udemy or youtube tutorial :D
We will think about it !
Hi Neat games Lol I found you XD
@@MiloTheDuck-s7j Oh hello :D I still want to learn how to make a Tower Defense game haha.
Was watching the 2d ranged weapon tutorial didnt understand a clue what the mouse following code meant came here and i understand that code now lol
Can anyone tell me if you use the paid for photoshop or the free Express one?
If you dont use either can you tell me what you use ?
Krita
@@ayokashodipe2263 thanks👍
Gimp
i use krita and i love my arts
I love this video man! And I haven't even seen it yet! : D
Hey! great to see you back!
Fine.....ffffff I missed those videos....finally ..I was waiting until this video XD...but yeah please continue your serie I want to learn from you
Is there any way to make line renderer length limit ?
line renderer endPos follow mouse position but line length goes infinite want line length limited.
Yay my man noa is back.
I really have fun at your udemy course.
This 2D strategy game is literally awesome. You guys make the project to expansive project. Really worth to check out guys.
Really thankful to noa and Liam for amazing course,and free tutorials!
dude,I love your tutorials they are very useful
Thanks so much !
Thanks so much, This helped a lot, I searched drastically for a tutorial for this and yours was by far the most effective and simplest.
Quick Question: Is there a way to stop the dots from showing after they collide with a platform, so that you never see the dots beyond the platform that it hits?
Hello Blackthornprod, i love your videos and because of them will get into game dev. I wanted to ask is starting to learn unity at 13 years old late?
Thanks again for inspiring me to get into game development
Yes, you’re too old. Most devs begin when they are younger than 5 years old.
Just kidding, you will never be too old to learn anything. And it is never too late to learn anything. However, things can be easier or harder at different times.
Haha you scared me for a second
@@Anerisian thats some real observation and motivation
İ started at 10 -_-
No you are starting very early, that's great ! We started later than you ! You are very welcome !
Incredibly helpful tutorial - thanks both of you :)
I used google translator
Why multiply 0.5 by gravity and add it?
And do you square the time here?
Are there any resources to understand the formula?
4:20 my object doesnt move with the cursor at all
Nice video guys, keep it up :)
Could you make a tutorial on how to draw, the style you have in this tutorial
Ahah we will think about it !
You are very helpful at all time for me😄
How would you make it so that launch force changes depending on how far the mouse is from the bow with a restriction on it?
in the Shoot method, you would multiply the velocity of the arrow by the distance between the mouse position and the bow position, and then clamp it between two numbers
Great Video! Thank you. Just started my own video series developing a procedural generated 2d rpg with Unity. :)
Thank you so much for always helping me❤❤❤❤
Great tutorial! Thanks for sharing (:
What is the song called at the beginning of the video? Thanks
Liam's actually my math teacher
Thanks so much I've been Searching for this
you're welcome !
hey men i have trouble using transfrom any gues? The type or namespace name 'Transfrom' could not be found (are you missing a using directive or an assembly reference?)
This took a lot of time to see your new video Noah!
Now this is some original BTP content!
When i move my sword gfx (child object) my empty game object (the parrent) follows so i can't set my pivot point, any fixes?
Realy good tutorial it helps me a lot
Finally making tutorials again :)
yeah we are back at it !
Thank you very much.
Such a nice tutorial.
🏹
How would you make the line thing for an a.i? Id like to show the user where the enemy is aiming before it attacks. Any help would be appreciated love your work
i love your tutorials
We need more lessons on unity 2d... "HOW TO MAKE"
And the links to the courses are of course INDIE description xD
ahah good one !
Can you do tips and tricks on how to make a game look as good as yours do? :)
We will think about it !
A tutorial after years 😄
Fun tutorial, has anyone gotten this to handle the fact if you are moving with arrow keys and pressing left faces the character left with the local scale .x to -1 ? If I face right it all works, if I turn left it is all off on the math, ideally the bow wouldn't even care what direction the player is facing but not sure how to make that happen sinced the Bow game object is a child of the parent.
Finally you made a tutorial about using unity, good luck with your game!
Hes made like a billion
@@zahhym I know but I'm talking about in a long time
Thanks !
I didnt understand the position formula that you used for the dots
I also. How the velocity in Newton formula change to distance in unity
Hey! Thanks for the tutorial. This is a super useful tutorial. I have an idea for a challenge. As you are very good at making games, how well can you make a game in scratch? It can just be a quick and easy challenge. Thanks for the tutorial!
It's our pleasure ! we will think about it
Pretty cool dude. How did your game do?
This is almost exactly what I needed, how would I go about showing the proper trajectory if I want my bullet to bounce off of objects? Right now the line goes right through objects with colliders even though the bullet itself is bouncing off of them.
Hi Noa, first of all, thanks for the awesome content you make! And my question is can this be used to mobile games also? Thanks! :)
Hey man, I was wondering how you would get an arrow to spin(like a throwing knife)? Thanks!
you are probably never gonna answer to this, but, how would i go about making the "shooting prediction" stop when colliding with objects?
I bet you love pronouncing that _Blackthornprod_ intro
Hi Guys. Vector2 position =(Vector2)shotPoint.position + (direction.normalized * launchForce * t) + 0,5f * Physics2D.gravity * (t*t); the error says '+' , cannot be applied to 'Vector2' and 'int'. something like this. I used brackets but did not work. Any suggestion ?
It is ok. I solved.
@@FFalanFilan how did u solved?
@@tubyuwu2320 I have not done anything in unity for a long time. But i will try to check the software if ı did not delete the unity itself.
@@FFalanFilan thanks
So this vids 11months old but figure I’ll ask anyway. What would be a good way to code it so player input can affect velocity and therefore trajectory? Was thinking something like holding the key down longer, makes the shot faster/straighter.
you would need to multiply the Velocity or Force with time the button is pressed.... well how to code is up to you ^^
Awesome work Noa and Liam! You guys make a great team! :)
Thank you ! We love working together !
Hey Noah and Liam I hope you guys see this because I need help. I am trying to do the Game Tiny Planets with your Tutorial but it isnt working when i am trying to do the play button. Do I have to create the button in the play image tab or in the Canvas because when i create the Button in the image tab it isnt working and when i create it in the Canvas it is working but the play button is HUGE
what is the "f" in 0.5f? thx for any help in advance
Sorry I'm a little bit late here. But I want to ask, is it possible if the pointer doesn't go through a collider/wall
This helped so much!
That was really awesome:)...Somehow can you pls give me piece of advice to make projectile collide .. it's actually overlapping objects.. Thanks in advance..
I am very very happy to see again noa´s tutorials 😍😍😍😍
plz do more and soonly😭
Is it possible to join the ranged combat script to this script? i'm trying to make a universal shooter for future games
Nice to see you back again Noa.. also Liam sounds a lot like you! Good video btw will definitely implement this in a future project..
Yay our man noa
I am really have fun in your strategy 2D course !Guys this strategy game is really fun and worth to buy. Literally amazing 😍.I bought topdown shooter too but I haven't done yet cause I literally have fun at 2D strategy game. Really really cool.Love u bro noa and Liam 🤩🤩
Thanks !!!
how can i make to shoot withaut rotation but in direction the player is walking
i cant shoot on the lef side only right
When setting the rotation, use rb.rotation instead of transform.rotation; this is guaranteed to be the actual position of the body. Transforms are not for the physics system; they're for everything else, like animations, etc.
Cool tutorial guys! :)
Wow. Liam explained pretty heavy stuff in an easy and light way. Would like more videos like this.
More comming up !
This is awesome dude!! Now I know how to make a bow power up in a platformer if I ever wanted too.
Glad it helped !
do you use a special program for creating and drawing these cute sprites?
Hi, interesting tutorial. If I wanted to move a 2D character according to the pointing direction of the mouse (without clicking) and moving the character only at the press of a button (for example W), how can this be done ? Have you already done a tutorial on this topic ?
u cud use MoveTo function or get the mouse position, as they did in this video, and use transform.translate or use the character's rigidbody and give it some velocity along the direction of (mousePosition - characterPosition) or something... it need not necessarily be as brief as i mentioned but is sure easy to understand
Did you figure it out? You would use something similar, find the angle. Find the distance between the mouse and character. Set your velocity, or add force as distance x movement speed in the direction
If i would add delay between the shots, so that the player just cant spam shoot. How would i do that?
So I followed the steps but it's not creating any arrows. I can see them being created in the sample scene but not in the actual game. Any idea as to why?
May I ask why not just set the rotation of the arrow to it's normalized velocity vector?
Thank you, man!
please tell me how to turn off the trajectory of the arrow
Hey Blackthornprod, I just discovered you today and I'm loving your content. I don't know if it's a recent change but the Udemy courses seem to be $50 dollars instead of $10. Was this only a limited-time sale?
Any idea about boomerang script !
Hey dude! Unrelated to the vid but could you consider putting some of your games on the switch E- shop? They would be great for it, would bring in some extra money and the switch needs it rn. The e shop is full of trash. Idk how how converting it would work tho, I’m an animator not,a game dev.
Nintendo is shit to deal with if i am right. It needs some extra work to get games there and putting games on pc is 100times easier. But still yeah it is possible and would be cool
AksimilumasPvP true true- from what I know is it’s not hard, just tedious. Otherwise how would trash and asset flips get on there?
Vector2 currentPosition =(Vector2)transform.position + (transform.right * force * t) + 0.5f * Physics2D.gravity * (t*t);
CS0034 Operator '+' is ambiguous on operands of type 'Vector2' and 'Vector3'
where am i going wrong ?
Awesome video as usual noa !
I'm learning a lot from ya ♡
Anyone know how I can change the launch force according to how long you hold down the Input key?
I have a question ¿Which text editor do you use?
where to download the the source code please tell fast????
lol is anyone else getting the "NullReferenceException: Object reference not set to an instance of an object
Bow.Update () (at Assets/Bow.cs:18)" when they put in the code? pls help lol
if you still need this after 1 month :)) . you need to have the dot in the hierarchy.
@@BogdanSlow lol thanks but i figured it out :))
Nice tutorial! However, it would have been easier to just use a line renderer for the points emanating from the bow.
I'm trying to make points work properly on my angry birds clone. Do you have any video guide suggestions that I can watch about this tip you just gave ?
Grear tutorial liam. However, u should show to cache most of the variables for better performans. I know this is a beginner tutorial but would be still good :) still a very good video 👍🏻💪🏻
Agreed! Especially when using camera.main, as that translates to a "FindObjectOfType()" if I recall correctly from one of the Unity Unite talks, which is really slow. Either create a reference in the script ([Serializefield] or public) and drag over the camera, OR at least in Start / Awake, call camera.main and store the reference for use in the script update. Camera.main use is mentioned in many tutorials and talks as a major performance issue so it is a good practice to get used to not using it in update / fixedupdate. Good job otherwise :)
TIP : On the arrow script use FixedUpdate() instead of Update() to have a smoother arrow.
Amazing. Really cool but very useful for my game
Great to hear !
Thanks, useful video
Why does the angle returns in radians what's the use of that kind of angles?
One thing i've learned through out my coding journey is... Don't question code.. lol