i wanna make drag and release or however it calls ball control system. also i want to do the big drags makes ball go faster. sorry for my bad english :))) pls someone help me about it… thank you so much
There’s a couple ways of doing this. Here’s one.
- Make sure your ball has a rigidbody
component, you’ll need to apply
forces to it. - Be ready for a lot of troubleshooting when multiplying the force times the delta.magnitude of mouse distance from original position.
Here’s some code in C# to get you started:
Vector3 delta = Vector3.zero;
Vector3 lastPos = Vector3.zero;
void Update()
{
if ( Input.GetMouseButtonDown(0) )
{
lastPos = Input.mousePosition;
}
else if ( Input.GetMouseButton(0) )
{
delta = Input.mousePosition - lastPos;
Debug.Log( "Delta Distance From Starting Position : " + delta.magnitude );
//multiply delta.magnitude times the force you want to apply to the ball and bam! magic!
}
}