I have a math problem I need for my script. What i'm trying to do is to apply a force to an object/person that depends on the distance between me and the target and our position in the 3d space as well.
My code so far:
Event OnEffectStart(Actor Target, Actor Caster);[..... not important stuff cutted]; calculate the distance between me and the target distance = Target.GetDistance(Caster) as int ;Debug.Notification("Player is " + distance + " units away from the target"); get my position myX = Caster.GetPositionX() as int myY = Caster.GetPositionY() as int myZ = Caster.GetPositionZ() as int; get target position targetX = Target.GetPositionX() as int targetY = Target.GetPositionY() as int targetZ = Target.GetPositionZ() as int; push target to my position with a force calculated on the distance between us ; PushActorAway must be done in order to use ApplyHavokImpulse next Caster.PushActorAway(Target, 0) Target.ApplyHavokImpulse(?, ?, ?, (distance/20))EndEventI need to calculate the ? to use in ApplyHavokImpulse, I made some tests but I can't figure out a universal formula that can suit me. I know it should be a piece of cake but now I regret every math lesson I skipped when I was at school a long time ago.
that "distance/20" is a work in progress I'll fix easily with trial end error, the direction is the issue...
tried with simply myX - targetX, myY - targetY, myZ - targetZ thinking that I was a genius but didn't work

(at first I tried to find the Telekinesis script to copy and modify it but I couldn't find it in the CK
)