Like this video, i want to allow user to select angle through trajectory line and distance will be constant(ball and goal net distance) and velocity will also be constant.
Then how will i make my ball to follow that path and if my ball hit the ground then ball should bounce again.
But i am facing problem how to write logic using this equations ?
Is there any other solution which give me same result?
I am facing so many problem since last week. I have tried so many code blocks and logic available. But could not able to derive the perfect solution.
You can calculate the final force based on landing point of the ball using projectile equation :
y = -0.5gt*t+v0*sin(a)*t+y0 ; //for horizontal movement
x = v0*cos(a)*t+x0 ; //for vertical movement
now . you know what landing position is , and you know what is launch position is . so everything is ok . replace your variable in the equation.
x0 = landPosition.x;
y0 = landposition.y;
y = launchPosition.x;
x = lanchPosition.y;
and you know what is gravity(-9.8) and you know what is your angle( a ).so get the v by replacing your variable in the equation and then you can reach the force :
F = m*a .
notice that your v is a vector . so if your mass is equal one unit the you ca use this:
F = v .
we used this way to launch our character to destination point ( Bingo dingo game ) .
Please guys help me.
– Ekta-Mehta-D