So i have been trying to make an Object(A) fire an other ball in 60 degrees and hit an 3:rd object(B) no mather the distance between the objects. , this fails big times, this is my calculation:

m*g*(x/2*tan(V)) = N

where:

m = mass of fired object

g = gravity

x = distance between object A and B

V = degrees to fire in

N = force needed for the ball to hit object B

and this is the script used in game:

```
import bgeimport math
cont = bge.logic.getCurrentController()
obj = cont.owner
scene = bge.logic.getCurrentScene()
ray = cont.sensors["ray"]
tim = cont.sensors["tim"]
fire = cont.actuators["fire"]
if tim.positive:
if ray.positive:
Target = ray.hitObject
# Formel:
# m*g*(x/2*tan(V)) = N
#constants
m = 1
g = 9.8
#variables
x = obj.getDistanceTo(Target)
print(x)
v = 60
V1 = math.radians(v)
V = math.tan(V1)
N1 = m*g
N2 = V*(x/2)
N3 = N1*N2
fire.linearVelocity = [0, N3, 0]
cont.activate(fire)
obj["tim"] = 0
```

the object that i use to att the canon ball whit is set to 60 degrees and the linearVelocity is set to use local cordinates.

the fiered ball is also set to have 1 as mass and 0 in damping

the result of the code is that the object flyes like 100 times to far away, do any one have any ide’s on what i’m doing wrong?