Everest Bytes hi Everest. Omg...Thank you for pointing that out. I went through the video and noticed that at about the 15.30 minute mark, I accidentally cut in another revision of the code in the video where I have changed the name of slingRb into hookRb. So hookRb = slingRb. Sorry for the confusion and hope it helps
@everestbytes1134
6 жыл бұрын
Hey no worries, I already knew that it was slingRb ... you did a great job there. I am learning Unity and your tutorial is awesome. Keep making more. Thanks.
@TheWorldBroadcast
4 жыл бұрын
Thanks for the comment I was doing this and was severely confused and had to rewatch the video several times before I realized he did this without actually mentioned it.
@sheepFactory
3 жыл бұрын
Thank you so much. Learned alot from this.
@janmatyoo3506
5 жыл бұрын
nice tutorial, i learn a lot from this one and i really need it for my game. Thanks! Also keep uploading more videos!
@czacha098
6 ай бұрын
the problem is wehn i move the bal my distancce doesnt change so i can move it freely without any limits
@Ce_AngelsVODS
2 жыл бұрын
Great video it helped me out a ton
@XfStef
5 жыл бұрын
Fast and concise. Good job!
@ramazanasfandi1262
4 жыл бұрын
Hello from Kazakistan,and biiig thanks for tutorial
@null21235
2 жыл бұрын
Step by step, very detailed :D
@onlysaying7745
5 жыл бұрын
Would be great if you could make this for touch screen controls, also ive done all the right code but when i click the ball it goes on top of the sling knob, it will not drag and once i let go of the mouse button it flys off? any answers? thanks
@FreakyFeet
5 жыл бұрын
Hi Stephen, really hard to know where it might have gone wrong with your code, but if you want, here is a link to the complete project. You can download it and compare to understand where the issue might be. www.jottacloud.com/s/160560aadca04374aacbd1a48c15e05eb92 Thank you for the suggestion. I will consider expanding the tutorial to cover mobile, however, as I have quite a lot to do at the moment it might take some while before I get the chance.
@irfanyigitbaysal7894
6 жыл бұрын
thx for lineRenderer ı have been searching for a long time
@niuka8688
2 жыл бұрын
thanks
4 жыл бұрын
This is the bestest video on the internetzzz!!
@sweetypatel7055
Жыл бұрын
Where are is starting setups video
@frankypappa
5 жыл бұрын
Great tutorial! Thank you for it! Subscribed! Is there any chance you can make a tutorial on how to add trajectory line/dots to the slingshot?
@FreakyFeet
5 жыл бұрын
Thank you so much for the kind comment :) I need to finish the beginner series I am doing at the moment (Pong game), but as soon as it is done I will see if I can put something about trajectories together!
@frankypappa
5 жыл бұрын
FreakyFeet thank you for your reply I really appreciate it! Cant hardly wait to see that? Do you have any predictions when you making that tutorial? In the mean time I’ll check your older ones. I just watched the draw gizmos and its awesome i didnt knew abt it I can do it and yet it would help me previously a LOT! 😅 anyway thank you again for the reply and keep up the great work!!
@FreakyFeet
5 жыл бұрын
:) Thank you again. Unfortunately no, no prediction. I have a really limited time that I can put into this channel currently, since I have two small children to attend to as well. So I am guessing it will come in a few months earliest. I understand you are probably eager to get it done and I wish I had more time to put into making tutorials.
@frankypappa
5 жыл бұрын
Hi@@FreakyFeet sorry just messaging back now, I just checked back for curiosity and seen your reply, I guess I didn't set up notifications properly, but I'll try fix it now. Congratulation for the children first of all, and huge congrats to you to do this channel beside all the "chores" :) yes you can say Im "eager" 😅 :D but completely understand what is more important no question!. I Thank you anyway in advance and God bless the family! :)
@programpurpose9782
5 жыл бұрын
This was well explained, thanks
@liuca97
3 жыл бұрын
HI! If i want to sling the birds without moving the birds, how can I do?? Thanks!
@yakanashe
2 жыл бұрын
Nice tutorial, i actually added my own things, but what if i want to retry?
@benrutt6878
4 жыл бұрын
Great Tutorial
@Jiierf
5 жыл бұрын
Is there a way to make this in a 3d space? Seeing as the Frequency property only exists in the SpringJoint2D is there another way to do it?
@FreakyFeet
5 жыл бұрын
Haven't experimented with the spring joint in a 3D space so I don't have any first hand experience. Instead of a frequency variable there seem to be the spring and damping that are important. I am guessing the important part you are after here is to calculate when the object should be released from the spring. That totally depends how on how Unity defines "strength". If checking up the physics for a spring we can see that to calculate the frequency we need to use the formula f=sqrt(k/m)/(2π) where m is the mass I guess of the object on your spring and k is the spring constant. So if strength is defined as the spring constant then you can use the formula directly. Otherwise you need to figure out what strength is first. Sorry if this isn't helping but unitys documentation for this is a bit vague and I unfortunately don't have the time to go try it out. Good luck
@ugotm3
3 жыл бұрын
Damn that's what i needed!
@b1rfp_889
3 жыл бұрын
for thoose watching in 2021 you need to change the code to { //the code you want to put } instead of { }
@aarnav526
4 жыл бұрын
my script is not working...i tried a lot...pls tell what to do..??
@FreakyFeet
4 жыл бұрын
Hi. Sorry to hear that. I am away at the moment, but when I get back tomorrow I can share a link to the project and you can compare it if you want.
@FantaLaTone
4 жыл бұрын
hey i want to use this system in 3d but there is no spring joint frequency how i can calculate release delay ?
@FreakyFeet
4 жыл бұрын
Hi Arda, A spring joint is an example of a harmonic oscilattor, for which the formula to calculate the frequency is f=(1/2π) √(k/m) where k is the spring coefficient (in this case I think the variable named spring) and m is the mass (probably the mass of the object you are going to drag). However, the frequency might also be just f=√(k/m) depending on normalization. I haven't tried it so you will probably need to do a little experimenting and see which is correct. The above case is assuming no damping however. If you want damping it gets more complicated and you will need to do some research on the subject. But I think that as long as you keep a relatively small damping it shouldn't affect the frequency very much. But once again, try it out and see if it is released somewhere acceptable. Good luck
@FantaLaTone
4 жыл бұрын
@@FreakyFeet thanks for the help
@b1rfp_889
3 жыл бұрын
I thought you meant 'higne joint' but i was dead wrong
@beratcimen1954
5 жыл бұрын
Thank you , it was a good tutorial. :)
@FreakyFeet
5 жыл бұрын
Glad you liked it :)
@pee0001
Жыл бұрын
The problem with tutorial is that by using .normalized it seems that the actual max distance is set to 1 unit, if you could tell me how to fix it that would be great. P.S this might be a mistake because I am a beginner :P
@FreakyFeet
Жыл бұрын
Hi @AKATitan, I don't know if I understand you correctly. What max distance are you referring to? The reason the direction is set to normalized is because we want to eliminate any speed magnitudes. Not normalizing it would mean it is not a direction anymore, but rather a velocity. However, we want the speed to be adjustable using the frequency field of the spring joint.
@pee0001
Жыл бұрын
@@FreakyFeet Oh I see I completely forgot the frequency thank you so much. However, because I want to expand my knowledge as much as I can if you could tell me how to make the distance between the sling and the bird longer that would be great. Of course, thank you again for showing me how to make the speed faster as that was my main goal.
@FreakyFeet
Жыл бұрын
@@pee0001 Is it the drag distance you want to increase? That distance is decided by the maxDragDistance property in the Ball script.
@pee0001
Жыл бұрын
@@FreakyFeet yeah but then it looks really weird if its anything apart from 1f, basically I'll be able to pull it far out and then it will teleport to a set distance from the sling edit: I have figured it out, all I have to do is multiply direction by MaxDragdistance
@walney2008
4 жыл бұрын
hello, could you make an example of a game similar to ddtank, where you have the aim and strength to shoot?
@TwitchTvQuagy
4 жыл бұрын
how to import it to game? like angry bird have it build in Rendering a Launch Arc
@FreakyFeet
4 жыл бұрын
Hi, Thanks for reaching out. However, I don't quite understand what you are asking..
@hypercausalgames
5 жыл бұрын
Good job!
@adamhilali806
4 жыл бұрын
I can't put the spring joint cause of the rigidbody
@FreakyFeet
4 жыл бұрын
I am not sure I understand what problems your are having. Can you elaborate?
@ryankopco1500
4 жыл бұрын
This is a month later but hopefully this still helps. Make sure you are using rigidbody2d instead of the 3d rigidbody.
@adamhilali806
4 жыл бұрын
@@ryankopco1500 thanks and can you go check my channel kzitem.info/rock/mup-1bErJLAZl3HR3TSTdg
@Ashiiru
4 жыл бұрын
this helped me a solving one bug but one of thhe bugs is still up you can pick up the ball after you shoot it, how do I desactivate a void? Im lost grat video tho :))
@FreakyFeet
4 жыл бұрын
To do this I guess the simplest way is to introduce a new bool: isReleased that is set to true when the ball is released. And while this is true then the DragBall method should not run I guess.
@Ashiiru
4 жыл бұрын
@@FreakyFeet ty for responding fast I will try it
@Ashiiru
4 жыл бұрын
@@FreakyFeet hey man, thank you it didn't work 100% cause the player still can pick the ball up all tho the physics of the joint dont work anymore , so its solved I guess, thank you for sharaing your work with us +1 sub
@allblakesmusic1606
2 жыл бұрын
ive messed up 2 things can you find whats using System.Collections; using System.Collections.Generic; using UnityEngine; public class ball : MonoBehaviour { private bool isPressed; private Rigidbody2D rb; private void Awake() { rb = GetComponent(); } void Update() { if (isPressed) { DragBall(); } } private bool DragBall() { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); rb.position = mousePosition; } private void OnMouseDown() { isPressed = true; } private void OnMouseUp() { isPressed = false; } }
@FreakyFeet
2 жыл бұрын
Hi, Not sure what you mean that you have messed up two things? I can find one issue in the code you have sent though. private bool DragBall() is not returning a bool and you are not expecting it to. You should change it to a void: private void DragBall()
@topmusicadancinrichard8701
4 жыл бұрын
what is hooks at 16:17?
@FreakyFeet
4 жыл бұрын
Hi, sorry about that. When editing I accidentally cut in another version where I instead used the name slingRb. Sorry for the confusion
@topmusicadancinrichard8701
4 жыл бұрын
@@FreakyFeet Thank you!
@swopestudios3776
3 жыл бұрын
Hi! Not sure what I did wrong here but when I go to sling my ball, it always goes down instead of straight or up. What did I do wrong? Here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Ball : MonoBehaviour { private bool isPressed; private Rigidbody2D rb; private SpringJoint2D sj; private float releaseDelay; private float maxDragDistance = 2f; private Rigidbody2D slingRb; private void Awake() { rb = GetComponent(); sj = GetComponent(); releaseDelay = 1 / (sj.frequency * 4); slingRb = sj.connectedBody; } void Update() { if (isPressed) { DragBall(); } } private void DragBall() { Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); float distance = Vector2.Distance(mousePosition, slingRb.position); if(distance > maxDragDistance) { Vector2 direction = (mousePosition - slingRb.position).normalized; rb.position = slingRb.position + direction * maxDragDistance; } else { rb.position = mousePosition; } } private void OnMouseDown() { isPressed = true; rb.isKinematic = true; } private void OnMouseUp() { isPressed = false; rb.isKinematic = false; StartCoroutine(Release()); } private IEnumerator Release() { yield return new WaitForSeconds(releaseDelay); sj.enabled = false; } }
@FreakyFeet
3 жыл бұрын
Hi Swope Studios, sorry to hear you are having issues. I have compared your code to my own and they are the same except for the line renderer part which you haven't included. So the issue must be in your settings somewhere. I don't quite understand exactly what issue you are facing, but from what I hear it might be some settings with your rigidbody that are different. Perhaps the gravity scales or something? If you can't solve it you can send me the entire project and I can take a quick look
@swopestudios3776
3 жыл бұрын
@@FreakyFeet Okay thanks, I will give er a shot.
@swopestudios3776
3 жыл бұрын
@@FreakyFeet I fixed the problem, it was an inspector problem. Thank you so much!
@FreakyFeet
3 жыл бұрын
@@swopestudios3776 great to hear :)
@FacuSalco
Жыл бұрын
@@swopestudios3776 I know it has passed a long time, but im having the same problem, how did you fix it?
This only works if the Sling gameObject or the place you are connecting to is called Hook. private void Awake() { rb = GetComponent(); sj = GetComponent(); // -> under me
@sudahmalam1
5 жыл бұрын
u help my project :)
@hachemben9383
5 жыл бұрын
can you please do another video beacause the new unity version dont support this thanks
@FreakyFeet
5 жыл бұрын
Hmm... I will have to take a look. I didn't know there where breaking changes
@kaoeferreira9933
5 жыл бұрын
All credits goes to Brackeys, you simply copy the code from the original video. Thats ugly !
@FreakyFeet
5 жыл бұрын
I am not denying that I have used Brackeys tutorial as inspiration for this. However, I wanted to keep the focus on the sling mechanic and also improve on it where I was able. I am actually thinking about doing the same to the AudioManager tutorial which is another great tutorial by Brackey. However, I see parts that can improve. Simply copying it is one thing, but I understand, try it out and improve on it while finally giving a bit more in depth explanation. But you are right, I should have referred to his tutorial as well. I am sorry you don't like it.
Пікірлер: 79