How do I move and collide my object (position given by touch or click), by Using rigidBody2D.MovePosition i can only teleport my character, and by using velocity, my character keeps moving, I want him to stop at the position given
Ilustrations:
How do I move and collide my object (position given by touch or click), by Using rigidBody2D.MovePosition i can only teleport my character, and by using velocity, my character keeps moving, I want him to stop at the position given
Ilustrations:
This is called arrival. It's a steering behavior. The basic concept is:
You can find a good explanation of the implementation here.
You'll have to change the velocity after your object reaches the correct position. You could store the target position in your script, and you could check the distance to the target during Update. Once the object has arrived, set the velocity back to zero. Arrival should be determined by some non-zero minimum distance to the target, because the object is unlikely to land exactly on the target position. If you like, you could then move the object perfectly to the target position as one final step.