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
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?
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
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)
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.
@@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
@@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 :)
Very helpful and clear video
thank you very much :))
THANK YOU!! Helped me out sooooo much!
Very good tutorial, thank you!
You can use Pointer instead of Mouse and Touchscreen for both press and position. Pointer is an abstraction over both.
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
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?
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
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)
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.
@@GameDevGeeks Don't we need to unsubscribe using -= in an OnDisable method?
@@Mehrdad995 it's generally a good practice to help GC but unless you want to destroy the object unsubscribing would'nt do much.
@@GameDevGeeks Thanks for your help.🙏
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 ?
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)
thanks a lot @@GameDevGeeks
@@sameralkhalili6554 glad I can help
When i drag this object and want to drag another, how can i do to get rid of the first object?
Hi👋 if both objects have colliders and the drag&drop script set up on them it should work with both of them.
If you have any questions ask them here :)
how to Drag the object fast and throw it far away ?
@@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
Have you got a version for 2D without physics?
Why does the drag method return Ienumerator?
@@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 :)