Hi i was thinking of a game idea and i need some objects to be throwed away after being unclicked(released) i mean you click on them you drag them so you have given them some speed then you throw it away with uncliking it so i thought i must have rigidbody which is also a trigger how can i handle this ?!?
I’ve tested it with a boolean of HasClickedOn & Input.mousePosition.x but it is not working well (it’s not connected to the Mouse it’s somewhere around it!!)
What Code should i use?(Although i prefer JS but you can answer in both JS and C#)
The endgame here is to use the function rigidbody.AddForce. The tricky part will be to find the vector.
You need to register the position of the object being dragged every x frames, so when the player release the mouse button, the vector to use with addForce is currentPostion - lastPosition. You might want to use a factor for the force here as well. That’s the simplest way I can think of.