# Faithplate

I’ve been struggling with this (it’s vector math again, whew) I need to make a faithplate like in portal 2, and I’m not sure how I should figure out what direction to apply the force in. Do I need to do something with getVectTo? Is there an easier way?

Maybe you have to combine the (front) direction of the player with the up direction of the plate. Keep in mind (and I’m a total savage in math) that directions are the simplest thing one can imagine: you take one point as the origin, one point as some destination, you do:

sub = destination - origin
sub.normalize()

and sub is the direction. If you want to mix two directions, just add and normalize again:

sum = dira + dirb
sum.normalize()

So if you have the direction the player is walking on (that is the worldLinearVelocity of the player) and you know the the plate forces up, you can do:

up = Vector((0,0,1))
front = player.worldLinearVelocity.normalized()
forceDir = up + front
forceDir.normalize()

and then you say:

force = 10000
forceVector = forceDir * force
player.applyForce(forceVector, False)

(In uncertain theory) this should make the player jump up and forth. If you multiply the linearVelocity vector of the player by some value, before to add it to the up direction, you can lean the angle of the jump toward the direction of the player.

Maybe.

Thanks, but I need the velocity to be applied based on the way the faithplate is facing, and since it wont be moving I can’t use the method you used to find the front. Do you know how I could figure that out? Everything else you said will work great, I’m not the greatest at applying math so thank you

You can find a vector for the way something is facing using:

``````
front = plate.getAxisVect([0,1,0])

``````

(for the y axis being forwards)

Oh awesome! thanks sdfgeoff(spelling?)

So I’ve put together this script, but it doesn’t fling you forward very much. What I think happens is that it stops applying the force as soon as the player isn’t touching the trap anymore, is there a way to keep it activated for a while? I already tried just multiplying the y by a higher number, it doesn’t give good results Here’s the script

``````
from bge import logic as l

def main():
scene = l.getCurrentScene()
cont = l.getCurrentController()
own = cont.owner

trigger = cont.sensors[0]
hitob = trigger.hitObject
frontvect = own.getAxisVect([0, 1, 0])
upvect = own.getAxisVect([0, 0, 1])
flingvect = frontvect + upvect
flingvect.normalize()
flingforce = 1500
print(hitob)

if trigger.positive:
hitob.applyForce(flingvect * flingforce, 0)
``````

Works just fine for me for dynamic/rigid objects. A possible cause to why it may be stopping is because of a script attached to the object you are trying to fling. For example, if it is a player object, it might be because you are setting its linear velocity.

Yep, that was it! Thanks MrPutu