Was this tutorial useful? Would you like more tutorials on the elements of games I make?
@Luckysury3334 жыл бұрын
YES IT WAS SUPER USEFUL!!! Can you make a video where we can see where the ball is going to head if we pull like those dotted line in Angry Birds??
@MuddyWolf4 жыл бұрын
Hmmm, yes maybe I will do a trajectory line video !
@Luckysury3334 жыл бұрын
@@MuddyWolf I am getting ready for Ludum Dare 46 this 17th of April.....hope you will be also joining (in case if you don't know what is ludum dare, it is one of the world's largest game jams search google for more info)
@MuddyWolf4 жыл бұрын
@@Luckysury333 I am this will be the first one I join. To be honest I'm not the best at game Dev! I'm trying to get better but practicing then showing off what I learn in a tutorials for others!
@utsavsingh11284 жыл бұрын
@@MuddyWolf Yes trajectory line video would be great.
@hammadmmusic6 ай бұрын
Absolutely nailed it! Even after 4 years, this is such a gold tutorial. You earned yourself a like and a sub
@MuddyWolf4 ай бұрын
Awesome, thank you!
@TurkishiOSGaming4 жыл бұрын
You are a great teacher. You got everything; fun, educative and not boring...
@MuddyWolf4 жыл бұрын
Thanks!
@CodeBlues-TimeisGold3 жыл бұрын
It's a 3D project, but we can change the z value to y value. Thank you very much for making a very useful tutorial. I wish you happiness.
@ettienneswart17192 жыл бұрын
you are a lifesaver mate
@Luckysury3334 жыл бұрын
This is an underrated Channel for sure here you are gifted with a sub
@MuddyWolf4 жыл бұрын
Thank you! I've started to put in works for future videos. A devlog will be on the channel tomorrow! :D
@craezyfx6084 жыл бұрын
You are very underrated! This is very helpful. Thank you.
@MuddyWolf4 жыл бұрын
Thank you
@barrybee46105 жыл бұрын
Damn dude you make awesome tutorials! Idk why you dont have more subs
@xliquid14004 жыл бұрын
thanks, man this video was awesome, slowly and good explained, you spoke clearly, and I could understand every word, unity tutorials should always be like this subbed :)
@MuddyWolf4 жыл бұрын
Woo!
@BarryConnolly-w2n Жыл бұрын
Lovely Turtorial precise and easy to follow !!
@MuddyWolf Жыл бұрын
Glad you liked it!
@Forestfire8374 жыл бұрын
Didn't use the whole tutorial, but was definitely very useful with working out how the line renderer works! Looking forward to watching more of your videos :)
@MuddyWolf4 жыл бұрын
Awesome!
@Alex-eq2um5 жыл бұрын
14:54 😂😂😂 And great video by the way, really helped with my game.
@magikalo3 жыл бұрын
OMG thank you so much, i've tried to do this for 3 days and finally it's working, thank you !
@joshlim85954 жыл бұрын
Great tutorial! Explained really well and easy to understand
@MuddyWolf4 жыл бұрын
Thanks! 🙌
@Катюша-щ5ю2 жыл бұрын
I can't thank you enough, it works, figured the first time didn't work because I got some lines wrong
@arthur-monteath4 жыл бұрын
this channel is incredible
@megames45214 жыл бұрын
It's sad he didn't post for 4 months.. :/
@MuddyWolf4 жыл бұрын
It's coming back! I'm coming back! Woop!
@MuddyWolf4 жыл бұрын
More to come soon!
@megames45214 жыл бұрын
@@MuddyWolf Nice
@mehrshadeftekhari60094 жыл бұрын
Amazing.👌 I was using it for a touch-controlled game and change a few things in there. but anyway the Explanations were really good(others won't say which code is doing what or what is this line of code we are writing is for. I mean we learn it as you do it cause u explain everything, and we are not just copying everything you type without being able to configure it for our own game later or understand it. tnx a Lot.😊
@rubikscube67714 жыл бұрын
Wow, thanks. That is one of the best tutorials i have ever seen:)
@MuddyWolf4 жыл бұрын
Wow, thanks!
@vrmsali3 жыл бұрын
Awesome tutorial. First thing i will try tomorrow morning after my round of golf.
@mistercoder65944 жыл бұрын
Exactly what i was looking for, thank you so much :)
@subharanjanghoshal55973 жыл бұрын
This was definitely useful. Thanks a lot for creating this tutorial.
@AveryLiligant4 жыл бұрын
Thank You for this tutorial. It was very useful and well produced too :)
@MuddyWolf4 жыл бұрын
You're very welcome!
@Dome310719894 жыл бұрын
Thank You! That's exactly what I need Greets Dominik
@MuddyWolf4 жыл бұрын
🙌🙌
@TheSaucerful4 жыл бұрын
İ have a problem; my line start from mid of the screen and lenght of line is very short. How can i locate close to the player and make it size longer?
@rapizer34275 жыл бұрын
This tutorial is extremely helpful thanks a million!
@MuddyWolf5 жыл бұрын
Happy it helped!
@abhinawram4014 Жыл бұрын
On dragging it actually control the ball throwing force like( if mouse dragging length is short the force applied on the ball is low competitive the longer drag).
@simontriulzi39163 жыл бұрын
so i was wondering, how do you make it so you can only use it a certain amount of times when you are in the air and when you touch the ground it resets?
@iaroslavpodkovenko61182 жыл бұрын
I've got error at 21:26 : There is no argument given that corresponds to the required formal parameter 'position' of 'LineRenderer.SetPosition(int, Vector3)'
@iaroslavpodkovenko61182 жыл бұрын
nevermind, I've writed lr.SetPosition(points); instead of lr.SetPositions(points);
@FlimzyYT2 жыл бұрын
If you want to make it so you can only drag when the object is still, Then the DragNShoot script will be this: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float power = 10f; public Rigidbody2D rb; public Vector2 minPower; public Vector2 maxPower; TragectoryLine tl; Camera cam; Vector2 force; Vector3 startPoint; Vector3 endPoint; bool isStill = true; private void Start() { cam = Camera.main; tl = GetComponent(); } private void Update() { if (rb.velocity == new Vector2(0, 0)) { isStill = true; } else { isStill = false; } if (Input.GetMouseButtonDown(0) && isStill == true) { startPoint = cam.ScreenToWorldPoint(Input.mousePosition); startPoint.z = 15; } if (Input.GetMouseButton(0) && isStill == true) { Vector3 currentPoint = cam.ScreenToWorldPoint(Input.mousePosition); currentPoint.z = 15; tl.RenderLine(startPoint, currentPoint); } if (Input.GetMouseButtonUp(0) && isStill == true) { endPoint = cam.ScreenToWorldPoint(Input.mousePosition); endPoint.z = 15; force = new Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x), Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y)); rb.AddForce(force * power, ForceMode2D.Impulse); tl.EndLine(); } } } Here I created a bolean called "isStill". And in the void Update() I made isStill = true if the velocity of the rigid body is = new Vector2(0, 0) And if its not (else), then isStill = false. And then for each if statement we made I added (&& isStill ==true) to make sure the object is still to be able to perform this action
@marvinrosales3483 Жыл бұрын
hi, how can i do this in 3D? what would be the code? sorry to bother you my friend.
@redtriangle920Ай бұрын
holy shit dued, thank you
@djdee043 жыл бұрын
@muddywolfgames awesome tutorial. have just one doubt ,,,, how do i show the power when the player interacts with game. i mean at the start of the video 0:10 i can see there is a power at the top centre, how can i achieve this?
@crazy59484 жыл бұрын
absolutely amazing exactly what i was looking for thank you
@SmashBros43393 жыл бұрын
Also, anytime I drag and shoot and collide with 2 or 3 box collider platforms, the drag and shoot doesnt work. Any fix?
@organl52103 жыл бұрын
thank you so much Muddy Wolf games. This was really helpful for me!
@skamzababy60174 жыл бұрын
lovely video mate
@jakeyyyyyyyy2 жыл бұрын
My left ear really enjoyed that one
@MuddyWolf2 жыл бұрын
Your left ear? 🤣
@3Fingrd Жыл бұрын
Followed the video and on finish the line renderer seems like it's attached to the ball object, so when i drag it spawns the line next to the ball rather than where I click. Did I miscode it or miss box tick in a menu or something? Either way awesome video :) thanks for putting it out
@prabinadhikari30375 жыл бұрын
hello,how can i make the line follow the camera? so,i am making the game where the camera follow the gameobject..when ever i try and draw the line ,the startpoint moves off the camera and i dont want this to happen...i want to follow the camera like ur game which shows at beggining ..please help
@Mandrilmen_84 Жыл бұрын
Hello! Thank you very much for the tutorial! I'm having issues when I set the camera to perspective mode. It only works correctly if it's in orthographic mode. Has anyone else experienced this? How can I solve it?
@VoderPoint11 ай бұрын
everyone i know im late to the party but i need help i followed everything but unity says "The type or namespace name 'TrajectoryLine' could not be found (are you missing a using directive or an assembly reference?)" pls help me ive been stuck for two days !
@Diogo-md7rb10 ай бұрын
it's because of how the LineRenderer script is named, probably your script was not named "TrajectoryLine", try it out
@walney20084 жыл бұрын
hello, could you make an example of a game similar to ddtank, where you have the aim and strength to shoot?
@ShavDance3 жыл бұрын
Your video helped me to start developing a game that will be amazing. When I finish and upload it on steam you will get it for free.
@MuddyWolf3 жыл бұрын
Have fun! I'm excited to see what you create! :D
@hellclown2104 жыл бұрын
Amazing tutorial , Thank you so much !!!
@MuddyWolf4 жыл бұрын
Glad you enjoyed it!
@Squarerians2 жыл бұрын
i want to add cooldown for this shooting thing. please answer and tell us how we can add cooldown for this game please Cheers -your lovely followers :)
@MuddyWolf2 жыл бұрын
There's 2 ways you can do this! Either a by using coroutine function or by setting a boolean and setting it true after a timer, I would recommend looking into coroutines!
@Squarerians2 жыл бұрын
@@MuddyWolf i didnt understand that how can i do cooldown with using coroutine system. Can you show me one video that shows how can i add cooldown to my game using coroutine system please? I tried a lot of tutorials but they didnt work.
@GVG5852 жыл бұрын
Great Tutorial! But unfortunetly it didn't work for me but you know it's okay, It was good explaining and atleast i learned alot with input, Thank you!
@zergium2 жыл бұрын
idk if you are gonna respond to this because it's been 2 years sience you made this video but the tutorial is great i just have an issue with it: the players can spam it and they can fly so how do i make like a cooldown system or that if the player stops moving then they can move again or something?
@section8entertainment9612 жыл бұрын
So what I did was create a boolean variable to track whether the player has used their drag and shoot ability or not. I wanted the player to have one chance to use the drag and shoot function and thats it. And when the player respawns it re-enables it. bool hasShot = false; if (Input.GetMouseButton(0) && !hasShot) if (Input.GetMouseButtonUp(0) && !hasShot) { hasShot = true; } Then, in my respawn Coroutine I just added hasShot = false; so for you, I would recommend doing like a Coroutine WaitForSeconds and then setting the boolean variable back to false or something of that nature.
@alexandruaioanei74574 жыл бұрын
Hey man, I've really liked your tutorial and it helped me a lot; but can you help me with something? After I added animation to the script the ball only jumps straight in the air, it doesn't jump on the right or left part, do you know any solution for this? Thanks in advance!
@firatsezgin12895 жыл бұрын
I am thankfull to reddit for sending me to you
@MuddyWolf5 жыл бұрын
Woo, I'm happy you came! I hope you enjoy your stay! 😁
@Gupatik2 жыл бұрын
I just don't understand what's the first parameter in the Mathf.Clamp( ) function and I don't get the use of it. Otherwise, everything else is clear. Thank You!
@OAAA.13 жыл бұрын
How to make it limited like 3 shots then its gameover
@Dubutofuuuuuu10 ай бұрын
where did ub get the shapes from
@karthikpoluri6372 Жыл бұрын
Im getting null reference on line 39 and 49 in DragNShoot script
@jimkika2 жыл бұрын
Dummy question here: I have a ball with 9 child bones( to create the soft body effect). Initially, the script applied only to the rigid body "Ball" had no effect, so I've added the same script also to each bone and it works perfectly. With that said, is there another way of doing it? Not sure if that's the most lean way. Thanks
@Mohamed_Salah_Lovers2 жыл бұрын
Use the scripts in the middle only bone
@mr.waddles20274 жыл бұрын
Hey excellent video but I have a question How do you get the autocomplete and definition thing for unity because when I type it doesn't show all the options you have
@Isica2234 жыл бұрын
Nice video! thanks, but how can i make the line attached to the ball?, if i disable use world space, still the line render where i got the mouse.
@TiimedArts4 жыл бұрын
exactly what i was looking for
@MuddyWolf4 жыл бұрын
Awesome!
@g8torx8613 жыл бұрын
When I try to add another line renderer for my player to make it so it has a trail while its moving and its not working. Does anyone know how to fix this?
@reya.99153 жыл бұрын
Awesome tutorial!
@rubikscube67714 жыл бұрын
I have a problem with the code:( Unity says no errors but when i just click without dragging it applys velocity on the y axis:( Can you/someone please help.
@FC12CGaming2 жыл бұрын
Thank You For The Tutorial! I Am Working On A Stickman Game And With This I Can Make It Have Unique Movement
@unscriptedlogicgames4 жыл бұрын
Yeah it works! However, it isnt accurate for me. Any idea why?
@MuddyWolf4 жыл бұрын
Hmmm, I'm not sure without seeing it
@unscriptedlogicgames4 жыл бұрын
@@MuddyWolf To give u an idea of what i was doing, i created a "Prediction line" which basically draws an arrow in the opposite direction using the Line renderer. But when I shoot the ball, the ball's final trajectory isnt the same.
@unscriptedlogicgames4 жыл бұрын
@@MuddyWolf In the end i resorted to the spring joint in unity. I used the spring joint for the pullback and just disabled it once it reaches the pivot point which works similarly to your video. Thanks a bunch anyway!
@SmashBros43393 жыл бұрын
Great Vid! But is there a way you can drag and shoot once until you hit the ground so you won't keep shooting up in the air?
@d.r17753 жыл бұрын
with a bool variable check if the ball is on the ground. or if collide with the boxcollider.
@orkhanhaddad14903 жыл бұрын
this didn't work for me and i have no idea what to do he tell me the cam doesn't exist
@overgeared20145 жыл бұрын
I didn't work for me, when i drag nothing happens Edit: Figured it out, for those of you who also have the same problem, change the second if statement to something like the one below if (Input.GetMouseButtonUp(0)) { endPosition = cam.ScreenToWorldPoint(Input.mousePosition); endPosition.z = 15; //sometimes the object will move even when you click so i made a new if statement //so object won't move unless you've dragged the mouse a more than 2 units if ((startPosition - endPosition).magnitude > 2f || (startPosition - endPosition).magnitude < -2f) { mforce = new Vector2(Mathf.Clamp(startPosition.x - endPosition.x, minPower.x, maxPower.x), Mathf.Clamp(startPosition.y - endPosition.y, minPower.y, maxPower.y)); rb.AddForce(mforce * power, ForceMode2D.Impulse); } }
@TiimedArts4 жыл бұрын
What is the difference?? I have the same Problem, i exactly made it like him but it is not working for me...
@carlosbeltran29753 жыл бұрын
Muchos thank's amigo, llevaba un buen rato dándole vueltas y no savia que hacer, hasta que puse tu código.
@johannes17912 жыл бұрын
What if I want to check is gameObject still? (Cant shoot mid air)...
@FlimzyYT2 жыл бұрын
Then the DragNShoot script will be this: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float power = 10f; public Rigidbody2D rb; public Vector2 minPower; public Vector2 maxPower; TragectoryLine tl; Camera cam; Vector2 force; Vector3 startPoint; Vector3 endPoint; bool isStill = true; private void Start() { cam = Camera.main; tl = GetComponent(); } private void Update() { if (rb.velocity == new Vector2(0, 0)) { isStill = true; } else { isStill = false; } if (Input.GetMouseButtonDown(0) && isStill == true) { startPoint = cam.ScreenToWorldPoint(Input.mousePosition); startPoint.z = 15; } if (Input.GetMouseButton(0) && isStill == true) { Vector3 currentPoint = cam.ScreenToWorldPoint(Input.mousePosition); currentPoint.z = 15; tl.RenderLine(startPoint, currentPoint); } if (Input.GetMouseButtonUp(0) && isStill == true) { endPoint = cam.ScreenToWorldPoint(Input.mousePosition); endPoint.z = 15; force = new Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x), Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y)); rb.AddForce(force * power, ForceMode2D.Impulse); tl.EndLine(); } } } Here I created a bolean called "isStill". And in the void Update() I made isStill = true if the velocity of the rigid body is = new Vector2(0, 0) And if its not (else), then isStill = false. And then for each if statement we made I added (&& isStill ==true) to make sure the object is still to be able to perform this action
@maddhi95313 жыл бұрын
Ive 1 to 1 followed the tutorial. The ball doesnt shoot. Help
@MatthewGruman3 жыл бұрын
Great video - thanks!
@hamster60394 жыл бұрын
How could i make dots, so before shooting , i know how object would fly
@DiuNeiMeeh5 жыл бұрын
thank you so much for the tutorial, I'm trying to make the line renderer start from ball instead of my mouse point when i drag anywhere of the screen and the line will expand the opposite way, can you pls advice.
@MuddyWolf5 жыл бұрын
There is a setting on the line renderer component that says use world space, if you uncheck this the line will draw from the game object! I hope this helps!
@fallendagger27665 жыл бұрын
@@MuddyWolf Yes it helps
@omersatran67005 жыл бұрын
does it work for mobile?
@shaquilleoatmeal74124 жыл бұрын
14:54 "OHHH it's gone it's gone far and wide" 😃
@tamla98754 жыл бұрын
Hi, how can I make trajectory line that predict the path that the object will travel? Like angry bird. Also please make a tutorial on Archery game.
@RajOnTheStreet5 жыл бұрын
Really helpful! thanks for the tutorial!
@jawka50353 жыл бұрын
Im making bow shooting game.How i can rotate my bow in the right direction with this script?
@ezekielthemack4 жыл бұрын
Sit back grab your snacks - love it. LOL
@MuddyWolf4 жыл бұрын
😂
@DarkDragonBloody4 жыл бұрын
Nice Video man
@MuddyWolf4 жыл бұрын
Appreciate it
@Jack_gav4 жыл бұрын
Just wondering, how would I go about setting the start point to an object e.g. the ball instead of a camera point? So that my drag starts from the object, thanks so much! Great tutorial
@thebonbadoor1084 жыл бұрын
You could use a raycast from mouse position and check for collision on an object by tag
@keremaslan19884 жыл бұрын
How can i instantiate an object in the trajectory lines direction? Can anyone help?
@cameronmiller49584 жыл бұрын
i keep getting error code cs1061 for the drag and shoot code and i dont know how to fix it can anyone help
@giannisroumeliotis41424 жыл бұрын
is there a way you can tell me how to change it instead of mousebutton to touch, for mobile uses, thank you :)
@MuddyWolf4 жыл бұрын
Hi! I'll make a drag and shoot with mobile touch controls sometime today.
@giannisroumeliotis41424 жыл бұрын
@@MuddyWolf great! thank you so much
@MuddyWolf4 жыл бұрын
Recorded, edited, uploading be out by 2/2:30 BST today
@giannisroumeliotis41424 жыл бұрын
@@MuddyWolf great! cant wait
@fallendagger27665 жыл бұрын
will this work for 3D the "Drag code"? thank you
@MuddyWolf4 жыл бұрын
I haven't tested it to be honest!
@skeep124 жыл бұрын
with TrajectoryLine is gave an error saying It could not be found, what happened?
@vatsalbhalani45544 жыл бұрын
Same problem, did you find a solution?
@skeep124 жыл бұрын
Vatsal Bhalani no :( I decided to not use the line at all, It was for testing anyway
@vatsalbhalani45544 жыл бұрын
Oh lol;-; I'm trying to make a line for a ball game just like this tutorial, maybe I'll have to watch multiple of them to get different ways of doing it
@keremaslan19884 жыл бұрын
@@vatsalbhalani4554 did you solve the problem ?
@RorschachsAsylum4 жыл бұрын
First, thank you for this awesome Tutorial!!^^ Why do you use Vector3 for startPoint and endPoint? What can be a problem with Vector2?
@Luckysury3334 жыл бұрын
Because he wanted the line to be shown if it was Vector2 you cannot change the startPoint.z which he did in the video 11:00
@codedontwrk11325 жыл бұрын
When i drag nothing comes up what should i do??
@DayDreamer40114 жыл бұрын
Dude you've helped me so much for this upcoming game jam! Thank you so much! Sub +1
@trkkkmatmat60704 жыл бұрын
Why my player jump in only y axis
@simpledeck51332 жыл бұрын
The script worked but the effect would only show a dot
@GameDevAnd3D3 жыл бұрын
nice tutorial, but how about on a 2d project with perspective camera?
@MohamedHassan-tp2tf5 жыл бұрын
Thank You so much
@amandixit17794 жыл бұрын
It's awesome ..but I really need help cause something came up and I'm really frustrated...I have made all the colliders as mentioned in the video but still, my player(ball) falls out of the area...Meaning no collision...Please if anyone has the solution for this please do help.....
@unityalexdev3 жыл бұрын
check the Z transform
@Muthugaming8434 жыл бұрын
Hey bruh how to do you learn unity can you share somethings to us......................
@MuddyWolf4 жыл бұрын
I just read the documentation! It's really useful!
@mahmoudshalabi86134 жыл бұрын
Hey! Could this be used in 3d
@donutbedum98374 жыл бұрын
Bro hell yeah this was useful. This is like the first thing I've ever done that works. Definitely subbing and watching your other videos. Can we have the source code? Thx!
@MuddyWolf4 жыл бұрын
Awesome, thank you!
@alexrizzo__934 жыл бұрын
Thank you!
@MuddyWolf4 жыл бұрын
You're welcome!
@aceadamgaming4054 жыл бұрын
When I drag it does nothing!
@MuddyWolf4 жыл бұрын
Hmmm, I am not sure why this is happening maybe if you share the script with me I could figure it out :)
@aceadamgaming4054 жыл бұрын
Muddy Wolf uhhh, well I found another tutorial and that seemed to make it work (the tutorial was made by octomanx) however, now that I have ur attention, I was wondering how to make a health system where each time an object hits you it has a chance of reducing health/reduces health? I’ve been spending a lot of time looking for a tutorial and I have no clue how to do it!
@MuddyWolf4 жыл бұрын
Odd, I was just making a health system but not by chance? Maybe you could use Random.Range(0, 1) and check if it is 1 and if it is 1 then take damage? That means you'd have a 50% chance to take damage! If this isn't useful then email me using my contact form on my website tylerpotts.co.uk/ and I'll help you fix it! :D
@farestutorials64253 жыл бұрын
Force = Vector2(Mathf.Clamp(startPoint.x - endPoint.x, minPower.x, maxPower.x), Mathf.Clamp(startPoint.y - endPoint.y, minPower.y, maxPower.y));, this is and error it says u cant use VEctor 2 like a method.
@jakublaszczyk14043 жыл бұрын
use "new Vector2(...code here)"
@greengamer20654 жыл бұрын
it not showing ridgidbody in code
@keremaslan19884 жыл бұрын
My trajectory line doesnt work can someone help please?
@xteclisx274 жыл бұрын
Gotta expound a bit my dude.
@bitmodelstudio4 жыл бұрын
how can i prevent multiple jumps?
@clumsycaden57084 жыл бұрын
yeah, make a boolean thats called in air. If it is in the air change the boolean to true. Make an if statement "if (boolean) is true" and pause the movement when its true
@bitmodelstudio4 жыл бұрын
@@clumsycaden5708 thx. i fixed already. 👍😀
@clumsycaden57084 жыл бұрын
@@bitmodelstudio oh ok, I thought so since you commented 2 weeks ago
@miuni8244 жыл бұрын
can i get your desktop wallpaper please?
@MuddyWolf4 жыл бұрын
I don't have it anymore and don't remember where I got it from... Sorry!
@phantombox43915 жыл бұрын
Nice Tutorial, we use similar functionalities in our game Rise Of Horizon. If you like, you can watch it on our channel and tell us what you think.