Apply force by clicking and dragging unity [closed]

0

Good morning, I'm a beginner in Unity so sorry if I talk nonsense haha

I'm developing a game where I need to put a ball in a basket, what I'm not able to do is click and drag the ball to apply the force and nor change the intensity gives strength according to the distance between the point where it is clicks and loosens our mouse. Does anyone know how?

    
asked by anonymous 05.04.2017 / 15:35

1 answer

1

You have to create procedures that handle an input event, such as "click and drag" (you have to study the Unity API). The procedures boil down to telling you what will happen when you click and drag the mouse.

You can increment a field as many required units per frame (learn more about how to implement from Time.deltaTime ).

You may decide that a slide on the mouse on the negative x-axis should increment the field and on the positive-x-axis the inverse. The value of the field at the moment in which to release the mouse button is what will determine the amount of force to which you must give direction and direction through an object of class Vector3 (for this you have to use the libraries of Unity physics).

    
09.04.2017 / 10:55