Bow Simulation

any chance I can simulate a type of archers bow attack through dragging backwards allows to fire the opposite angle of the drag…

Say I pull back on the character with an approximate 225 degree angle. Is there a way of converting that to on release fire an arrow at a 45 degree angle?

Hi @jazzarssoul,

Sure, this is fairly easy in principle. When the user releases the touch, I’d compare that event X and Y to the archer’s X and Y, and subtract the corresponding values to get values like -100, 100. Then, just apply an inverse force of 100, -100 to the arrow.

You’ll probably need to factor down higher values to a certain “threshold” too, so if the touch is far away from the archer (say -400, 300), you don’t fire the arrow at some insane velocity. Say the “max” of any allowed vector is 100 in any direction:

math.abs(-400) / 100 = 4

300 / 4 = 75

factored down forces: -100, 75

inverted: 100, -75

Hope that makes sense… I’m typing quick. :slight_smile:

Brent

Hi @jazzarssoul,

Sure, this is fairly easy in principle. When the user releases the touch, I’d compare that event X and Y to the archer’s X and Y, and subtract the corresponding values to get values like -100, 100. Then, just apply an inverse force of 100, -100 to the arrow.

You’ll probably need to factor down higher values to a certain “threshold” too, so if the touch is far away from the archer (say -400, 300), you don’t fire the arrow at some insane velocity. Say the “max” of any allowed vector is 100 in any direction:

math.abs(-400) / 100 = 4

300 / 4 = 75

factored down forces: -100, 75

inverted: 100, -75

Hope that makes sense… I’m typing quick. :slight_smile:

Brent