How To Make A Unity Mini Golf Game (part 1)
Vložit
- čas přidán 13. 06. 2024
- In this first episode on making a unity mini golf game, we go over the fundamentals of creating a system that allows players to click on the ball and drag in a direction to add a force.
► Socials
Twitter: / the_real_aia
Discord: / discord
My free web games: aiadev.fun/
► Part 2: • Making A Unity Mini Go...
► Get the script: unicornone.gumroad.com/l/mini...
► Details on the raycast function: • Unity Drag and Drop Sc...
► Download Unity 3D: on.unity.com/3cbxhXY
For more educational content on video game development, unity tutorials, and c# programming don't forget to subscribe!
Chapters:
0:00 Introduction
0:37 Setup
1:50 Visualizing the aim line
4:52 Toggling the aim
8:07 Adding force to the ball
11:15 Resolving a Physics timestep issue
11:41 Outro
····················································································
****
Get a 90% discount on a .fun domain for one year on www.get.fun using the coupon “AIA”
****
♪
#unity3d #unitytutorial #gamedev
Was considering making a mini golf game over the summer and this is the perfect start.
for a simple fix, easier for my brain to process as its what i am used to for games i have played in the past
instead of this
rb.AddForce(direction * strength * shotPower);
i did this
rb.AddForce(-direction * strength * shotPower);
just so you pull back on the mouse to increase power. ofc it is all preference, but this is what I prefer
Simple and explained well
Thank you!
Amazing video keep going :)
thanks :)
This its greath, thanks man!
You're welcome! Thanks for leaving a comment :)
Can anyone tell me the physics materials values i should attached to my ground and ball cuz my ball bounces and then goes in a straight line.... Plz help
When are we getting part two? I am excited!
I'm glad to hear it! I'll put something together soon
I don't know if you've seen part 2 yet but it went live last week! czcams.com/video/nPYoQ09q-xw/video.html
Nice video,really curious to know how you're gonna limit the player drag distance.
This could be done by splitting the worldPoint into a normalized vector3 and it's strength (vector3.magnitude). Then clamping the strength between 0 and some max value. Then we could reconstruct the vector3 based on that.
@@AIAdev I know this is an old video but could you provide an example of this? I've been trying to figure it out for hours now.
@@GreekGamerJim I didn't see the video but the logis is that the vector3.normalized is the vector with the minimium to get the direction, and the vector3.magnitude is how many minimiun (nomalized) fits in.
then you limiting the magnitude of vector (ex if the magnitude is 10, and you want the max to 5, you createnew verctor with minimium times 5, (normalized times 5 in this case)).
now you clamp the values based on that (limit these values between 2 numbers), starting from 0 to max value (max force applied to ball)
you can use chatgpt to help you on that...
Please make more parts to this
I’m currently working on a next part :)
Awesome
Thank you very much for the content! A question, I would like to change the direction that drags the mouse, instead of dragging forward, dragging backward, do you have any idea how to solve it?
Around 10:15 I add a ShotPower variable to the script. If you assign a negative value to that variable in the inspector the force that gets applied to the ball will be in the opposite direction of the dragged force.
@@AIAdev Thanks for the reply man! I actually meant it like this:
Currently in the script the player needs to drag the mouse forward and the line renderer will go in the same direction as the mouse, but how do I drag the mouse backward and keep making the line renderer show the same forward direction in the video, so the line renderer will go in the opposite direction of the mouse and the object will be thrown in the direction of the line renderer. Sorry for my English
@@kioka2 You could try doing some vector math to rotate the 2nd point drawn by the renderer by 180°. This seems like a case where Dot.Product would also work but I admittedly don't fully understand how to use that to be able to help.
@@AIAdev Thank you man!
haha was about to ask the same question
where did u get the box part and that from the start
I constructed it using Probuilder in Unity
For some reason it is random when i shoot the ball. Like the ball decides when it wants to shoot and when it doesn't. Do you know why this happens?
Without seeing your code and how your scene is set up, it’s hard to say. Feel free to join the discord in the description and I can help you out there
You are checking for inputs in the FixedUpdate function. FixedUpdate, instead of running once every frame, only runs once every physics tick, depending on the physics in your scene there may be more than one tick per frame or one tick every 10 frames.
thanks man helped me alot also my linerenderer in not displaying correctly like instead it displaying from the centre of the ball it appears on a random part of my screen, How do I fix this?@@GreekGamerJim
Very good video. How to make this works in android phone by the touch of the user?
Its a bit late but the mouse input already works with touch ive tried it
my linerenderer in not displaying correctly like instead it displaying from the centre of the ball it appears on a random part of my screen, How do I fix this?
do you have any solution?
@@GhazyAzhar I set the line renderer to "Use World Space" and it fixed this issue for me.
@@SerinitySW thank you
When's the next part?
Next week :)
@@AIAdev ok thanks