applyForce at exact direction without rotating!

Hello! I want to find out how to make an algorythm that applies a force at exact direction without rotating object to face it. It is like splitting total force value between 3 directions to get required direction. Is it possible somehow?

Get a vector to the point you want to move toward, and apply that vector as global force. You can also factor in a modifier to increase/decrease the amount of force being applied.


V = obj_A.getVectTo(obj_B)
mod = 50.0
obj_A.applyForce(V[1] * mod, False)     #V is a list [distance, localVector, globalVector]

This is the same principle used for aligning axes to a vector. You’re just applying the vector as motion instead of orientation.

OK! I will try when I can…

You may want to consider factoring in the object’s mass as well, depending on your situation, so it will apply a proportional amount of force to give the desired ‘kick’ to the object.


force = V[1] * mod * obj_A.mass
obj_A.applyForce(force, False)

OK! I will check tomorrow - won’t have time today and didn’t have for 2 hours.

Thanks Nines - I tested it and it works fine for me;)

V2 = own.getVectToTarget(target)
scaler=10
own.applyForce(V2[1]*(V2[0]*V[0]scaler),0)
own.worldLinearVelocity
=.8

if you use the distance in the equation it works pretty well for making a object fly to a spot and stop there without flying past,

by the way,

target.worldPosition-own.worldPosition = worldVectorToTarget

worldVectorToTarget.magnitude = distance

I need it to fly in that direction, but not measurely far. However - I need to somehow setup raycast to check if there is no obstacle in way and if there is, than reduce power modifier(the mod variable) accorting to distance of obstacle. Is this possible?