How to convert the mouse position to world space in Unity

Поділитися
Вставка
  • Опубліковано 26 лис 2024

КОМЕНТАРІ • 51

  • @GiantsOnTheHorizon
    @GiantsOnTheHorizon Рік тому +12

    I'm so impressed with your teaching style. You're such an asset to this community.

  • @grumpysalmon4153
    @grumpysalmon4153 Рік тому +5

    You're the first one that has explained the depth concept with such a great way. Amazing video!

  • @JuZZiO
    @JuZZiO 9 місяців тому +1

    Plane Raycast, what an amazing approach, no need to use game objects with colliders, great job!!

  • @robeeer2
    @robeeer2 2 роки тому +4

    17:32 I was desperately looking for a solution like this one, thank you so much!

  • @filipenobre6570
    @filipenobre6570 2 роки тому +3

    Awesome explanation, i could find the answer in a stack overflow post but i couldn't figure out how the code worked, thanks to you my character can now check the mouse position and teleport to it. Ty

  • @Novacification
    @Novacification Рік тому +1

    This was super clear and you went through both the infinite invisible plane, which I found a lot searching for this, and the position on a game object, which was the one I needed. And now I even understand the use case for both. Thank you!

  • @scottk4822
    @scottk4822 Рік тому

    I only watched to the 4 minute point because I'm making a 2d game, but from what I saw this was a very helpful video. Thank you!

  • @fievemax5720
    @fievemax5720 Рік тому +4

    Hey, thank you for your tutorial, it was really useful and I love the way you explain every detail along with the logic behind it. It's super useful while lots of tutorials tend to skip little details. Thanks you

  • @ondrejpolcar2872
    @ondrejpolcar2872 Рік тому +1

    Great how to. Explained nicely and to the point. And I also finaly understand, how Layer Masks are represented by int, even though I was looking for something different:)

  • @irminverhoeff5592
    @irminverhoeff5592 2 роки тому +2

    Thank you, this was helpful, i also found the bit about layermask values with binary interesting

  • @chozien7545
    @chozien7545 3 місяці тому

    Such a great tutorial. Thanks man.

  • @setharecool6459
    @setharecool6459 Рік тому

    Great video, I'm teaching myself Unity with only basic C++ under my belt before this, finding your explanations amazing to help me think out what I can do with the tools Unity gives which some tutorials don't seem to give. Thanks man and God bless

  • @KaganParlatan
    @KaganParlatan 2 роки тому +1

    Great explanation and plane raycast is so helpful. Thanks!

  • @Director414
    @Director414 Рік тому

    Great video! I love that you describe why things are happening, make learning much easier. 😊😊👍👍

  • @johanbello4701
    @johanbello4701 9 місяців тому

    Amazing video, really the best videos out there

  • @Sethizback1
    @Sethizback1 Рік тому

    Wow, plane raycast is a real life-saver. I hated setting up tags for every single floor tile in my game!

  • @carlozuk
    @carlozuk 2 роки тому

    Great video, you are very good explaining things, i will check your next videos for sure!!!

  • @JacquesLetesson
    @JacquesLetesson Рік тому

    Brilliant tutorial. Thank you!

  • @asdfghjkl123asd
    @asdfghjkl123asd 2 роки тому

    This was helpful. Thanks.

  • @aadityaprakash9756
    @aadityaprakash9756 2 роки тому

    This video was helpful thank you. Could you please share your setup details.

  • @antonsimkin
    @antonsimkin Рік тому

    Which method performs better?

  • @imadust
    @imadust Рік тому

    Following your tutorial. Any idea why the sphere is half inside the cube half outside it?

    • @GameDevBeginner
      @GameDevBeginner  Рік тому

      I'm guessing you mean the part on getting a point against a collider? the sphere's centre is at the point of impact, on the collider's surface, but, if you want it to appear as if it's touching, but not intersecting, you could probably find a point that's half a sphere back along the ray's path and move it there. There may be an easier way, probably using the ray, but, off the top of my head, something like get the direction from the point of impact towards the mouse world point as a unit vector, then multiply that the radius of the sphere, might work.

  • @avshkabura
    @avshkabura 2 роки тому +3

    Awesome) Thank you, hello from Ukraine)

  • @GameNajt
    @GameNajt Рік тому

    If I want to use the plane Raycast method but on a vertical plane, do I just change the up/down to left/right?`😅

  • @juezna
    @juezna Рік тому

    Been trying to use Raycast to move an isometric camera by clicking and dragging. So far I managed to move the camera but for some reason it flickers and i've tried lots of ways to avoid this (for example using LateUpdate) but cant get it to work for some reason.
    And if I dont use Raycast and just use ScreenToWorldPoint, the camera moves faster horizontally and slower when swiping vertically. Im losing my mind with this one

    • @GameDevBeginner
      @GameDevBeginner  Рік тому +1

      You may have already done this but first thing to check should probably be if this happens in a built version. A lot of Unity's choppy visuals are gone when you build a standalone build.

    • @juezna
      @juezna Рік тому

      @@GameDevBeginner thanks! I did not try this. But i will check it out. I "solved it" by just straight copying game dev guide's camera controller for a strategy game scripts. Lerping kinda hides the problem. But i know it's still there.

  • @JamesPhanJP
    @JamesPhanJP Рік тому

    awosame ! You are the best

  • @aaaalord
    @aaaalord 2 роки тому

    Thank you so much 💖

  • @queqerolul6514
    @queqerolul6514 Рік тому

    Thank you!

  • @dodgerfox
    @dodgerfox Рік тому

    Thanks!

  • @Alex-op2kc
    @Alex-op2kc 2 роки тому +1

    Thank you

  • @bobbville
    @bobbville 2 роки тому

    Nice vid!!🔥🔥🔥🍻

  • @Sovereing2027
    @Sovereing2027 Рік тому

    Thx a lot

  • @jasontravail8224
    @jasontravail8224 2 роки тому

    18 min to learn mouse position to world position ?

    • @GameDevBeginner
      @GameDevBeginner  2 роки тому +2

      TL DR: Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); if that helps!

    • @jasontravail8224
      @jasontravail8224 2 роки тому

      @@GameDevBeginner thanks for the answer

  • @thebeluvdtrex
    @thebeluvdtrex Рік тому +2

    Why does everyone teach the old Input system? The new one is superior...

    • @GameDevBeginner
      @GameDevBeginner  Рік тому +1

      For anyone looking to use these methods with the new input system (because I agree, it is better) you'll need to use a slightly different method for getting the mouse position: gamedevbeginner.com/input-in-unity-made-easy-complete-guide-to-the-new-system/#input_system_get_mouse_position

  • @okitkin
    @okitkin 7 місяців тому

    Thank you !

  • @lightninguy26
    @lightninguy26 6 місяців тому

    thanks so much