Directional Hitting (Like in Smash Bros)

So in Super smash bros, when you hit people your able to hit them in certain directions, depending on the move.


And in the BGE I already know how to the get the point of collision between two objects, and in this case, hit and hurt boxes.
Now I just need to know how to get the object to get knocked away in the opposite direction of what’s hitting it. I could use the BGE’s physics, but when I do that the object just get’s violently pushed this way and that and goes way too far. What I would like is a way to be able to control knock-back values and be able to get direction of getting pushed back.

Any suggestions on how I might achieve this?

Attachments


Apply force with the obj.applyForce(vector) function. where the vector is the angle/strength you want the knockback to be.

If you want to use collisions you can get the first contact position using a callback but that is overkill,
I would cast a ray along the leading edge of the attack and then if it detects, use a localized vector to the actor based on the attack.

to get a point in space relative to the attacker

point = attacker.worldPosition+(attacker.worldOrientation*Vector)

vectToPointFromAttacker = point - attacker.worldPosition

hitActor.applyImpulse(rayHitPosition, vectToPointFromAttacker*strength)

Works fine with a Dynamic Object, but unfortunately the Object I want to do it with is a Character Object, which doesn’t have the applyImpulse attribute. I do wish the Character Object came with the Dynamic objects attributes like the Force and Torque attributes. :confused:

So are there any ways to get a non dynamic object to get “hit” or moved in a direction?

I think it will have to do with applyMovement, but I don’t know how to get the Vector of applyMovement to move it in the desired direction.

Or wait, never mind, found out how to do it with applyMovement, I simply put the hitNormal in the X Y Z list, got the results I wanted, :stuck_out_tongue:

Thanks for the Help Guys! :smiley:

inputting the vector from the origin to the hitposition * a magnitude should give better results.

How would I do that? I’m not very python savvy, I don’t even know how to get/access a single x value from a simple xyz list. :confused: