Drag and Drop with New Input system! ( Touch and Mouse )

Поділитися
Вставка
  • Опубліковано 8 лют 2025

КОМЕНТАРІ • 26

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

    Very helpful and clear video
    thank you very much :))

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

    THANK YOU!! Helped me out sooooo much!

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

    Very good tutorial, thank you!

  • @bboysil
    @bboysil 3 місяці тому +1

    You can use Pointer instead of Mouse and Touchscreen for both press and position. Pointer is an abstraction over both.

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

    Can anyone help me?
    I want to adjust the settings of the game controls, it is for Android
    The settings are such that the party can move the fire button and customize it as he likes

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

    I like this method a lot. Is there a way to do this without having to put this script on your 'grabbable' objects? Also is there a reason you prefer to use properties instead of just calling the raycasts etc in your functions?

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

      Hi. there's definitely a way to do it without attaching a script to those objects but I found this to make sense and be more predictable.
      and yes when you do raycasts in a property the raycast runs only when you use the property instead of every frame if you do it in update for example and it's also cleaner like this I think, so that's why XD

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

    Can you write this code without using ternary operators? Im unsure why when you subscribe to the actions, like press.performed that you set it equal to _ , with a ternary operator afterwards, eg: press.performed += _ => (other code here)

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

      Hi Reid, performed is an event in InputAction objects and you can add method calls to an event (aka subscribing to it) and ( ) => is the syntax for anonymous functions but it you don't need any arguments passed to the anonymous function you can just put an _ there.
      so you can define a method and subscribe that to an event or you can subscribe an anonymous function to it.
      let me know if my explanation was not enough, cheers.

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

      @@GameDevGeeks Don't we need to unsubscribe using -= in an OnDisable method?

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

      @@Mehrdad995 it's generally a good practice to help GC but unless you want to destroy the object unsubscribing would'nt do much.

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

      @@GameDevGeeks Thanks for your help.🙏

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

    iam trying it in yellow head cap , which is on table , but it is fall down to floor ? , how can i back it to table again ?

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

      you need to add colliders to all the objects that you don't want to go through eachother (if you add a MeshCollider make sure to make it convex)

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

      thanks a lot @@GameDevGeeks

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

      @@sameralkhalili6554 glad I can help

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

    When i drag this object and want to drag another, how can i do to get rid of the first object?

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

      Hi👋 if both objects have colliders and the drag&drop script set up on them it should work with both of them.

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

    If you have any questions ask them here :)

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

      how to Drag the object fast and throw it far away ?

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

      @@supersocial9002 you may want to get the direction of camera to the object and add it to the objects velocity when its released but depends on what youre looking for

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

      Have you got a version for 2D without physics?

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

      Why does the drag method return Ienumerator?

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

      @@mrquokka4733 that is a Coroutine aka an async function, which means that this method will not block the execution and can run while other stuff is happening. you could instead have conditions in the Update method which runs every frame, but doing it with a coroutine is more performant and the code ends up cleaner.
      you can search for coroutines in C# to learn more about it.
      cheers :)