Tough Python Question

For my game Graviton, I am making a gun that works a lot like Halflife 2’s gravity gun. All the other attempts at this have used parenting which does not work because of collisions (you could move the object through walls and floors). I have my own way which works GREAT but I need to know one thing…

How (in python) do you make an object apply force to the direction of another object without tracking to it?

‘target’ is the target object, ‘impulse’ is the amount of impulse you want to apply

from math import sqrt

p1 = own.position
p2 = target.position
v = [p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]] # get vector pointing to the target object
l =  sqrt(v[0]**2 + v[1]**2 + v[2]**2) #get the length of the vector
v = [v[0] / l, v[1] / l, v[2] / l] # normalize the vector

own.applyImpulse(p1, [v[0] * impulse, v[1] * impulse, v[2] * impulse]) #apply the impulse

Thanks cyborg_ar. I’ll have to try that in a little while.