How To Make A Unity Mini Golf Game (part 1)

Sdílet
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

Komentáře • 46

  • @thefallenlime
    @thefallenlime Před rokem +3

    Was considering making a mini golf game over the summer and this is the perfect start.

  • @sourlesscream1272
    @sourlesscream1272 Před 10 dny

    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

  • @danegamedev
    @danegamedev Před 2 lety +1

    Simple and explained well

  • @Mathewx1111
    @Mathewx1111 Před 2 lety

    Amazing video keep going :)

  • @yarilcaos
    @yarilcaos Před 2 lety

    This its greath, thanks man!

    • @AIAdev
      @AIAdev  Před 2 lety

      You're welcome! Thanks for leaving a comment :)

  • @YoyoIsMeXD
    @YoyoIsMeXD Před 11 měsíci +1

    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

  • @Desvelar
    @Desvelar Před 2 lety

    When are we getting part two? I am excited!

    • @AIAdev
      @AIAdev  Před 2 lety

      I'm glad to hear it! I'll put something together soon

    • @AIAdev
      @AIAdev  Před 2 lety

      I don't know if you've seen part 2 yet but it went live last week! czcams.com/video/nPYoQ09q-xw/video.html

  • @markstar6899
    @markstar6899 Před 2 lety +4

    Nice video,really curious to know how you're gonna limit the player drag distance.

    • @AIAdev
      @AIAdev  Před 2 lety

      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.

    • @GreekGamerJim
      @GreekGamerJim Před rokem

      @@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.

    • @rc0d3
      @rc0d3 Před 11 měsíci +1

      @@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...

  • @kelpez
    @kelpez Před 2 lety +1

    Please make more parts to this

    • @AIAdev
      @AIAdev  Před 2 lety

      I’m currently working on a next part :)

  • @bestshorts4279
    @bestshorts4279 Před rokem

    Awesome

  • @kioka2
    @kioka2 Před 2 lety +1

    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?

    • @AIAdev
      @AIAdev  Před 2 lety +2

      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.

    • @kioka2
      @kioka2 Před 2 lety

      ​@@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

    • @AIAdev
      @AIAdev  Před 2 lety +1

      @@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.

    • @kioka2
      @kioka2 Před 2 lety

      @@AIAdev Thank you man!

    • @ProdbyHuskije
      @ProdbyHuskije Před 2 lety +1

      haha was about to ask the same question

  • @kadensim4000
    @kadensim4000 Před 2 lety

    where did u get the box part and that from the start

    • @AIAdev
      @AIAdev  Před 2 lety

      I constructed it using Probuilder in Unity

  • @irrelevantengine7488
    @irrelevantengine7488 Před 2 lety

    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?

    • @AIAdev
      @AIAdev  Před 2 lety

      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

    • @GreekGamerJim
      @GreekGamerJim Před rokem +2

      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.

    • @muhammadabubakar6149
      @muhammadabubakar6149 Před 7 měsíci

      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

  • @physicstech8057
    @physicstech8057 Před rokem

    Very good video. How to make this works in android phone by the touch of the user?

    • @YoyoIsMeXD
      @YoyoIsMeXD Před 11 měsíci

      Its a bit late but the mouse input already works with touch ive tried it

  • @muhammadabubakar6149
    @muhammadabubakar6149 Před 7 měsíci

    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?

    • @GhazyAzhar
      @GhazyAzhar Před 4 měsíci

      do you have any solution?

    • @SerinitySW
      @SerinitySW Před měsícem +2

      @@GhazyAzhar I set the line renderer to "Use World Space" and it fixed this issue for me.

    • @sourlesscream1272
      @sourlesscream1272 Před 10 dny

      @@SerinitySW thank you

  • @kelpez
    @kelpez Před 2 lety

    When's the next part?

    • @AIAdev
      @AIAdev  Před 2 lety +1

      Next week :)

    • @kelpez
      @kelpez Před 2 lety

      @@AIAdev ok thanks