BGE Shift F script

Hi! I’m working on an Attack on Titan game, and the problem I’ve run into is the 3D maneuver gear. I know that Shift F in BGE causes a 3D camera,that can also speedily move to the location pointed to. I was wondering if someone could send me an in-game-engine script to that does that, but can still be dynamic, and moved around. If not, how could one be made?

object 1 = player body (running script)
object 2 = player mouse look head (has property head)

keypress-------------and----------effect time=1
effect time=0-------/

if effect time min: 1 max: (end length-1)-------and-------add 1 to effect time

if effect time = end length -----------and------------effect time = - 120 (cool down)

if effect time is less then 0-------------and------------add 1 to time

(this is just to time the duration of the effect (you can always abort by setting the value of time to a negative number)

if effect time min 1 max end length----------python

import bge
from mathutils import Vector

cont = bge.logic.getCurrentController()

own = cont.owner

if 'head' not in own:
    for child in own.childrenRecursive:
        if 'head' in child:
            print('found head')
    if own['EffectTime']>=(120):
        if type(own['Target']) is str:
            print('Casting Ray')
            AXIS = 1
               ## if head forward axis is X AXIS = 0
                ## if head forward axis is Y AXIS = 1
               ## if head forward axis is Z AXIS =  2
            RANGE = 100
            end = own['head'].worldPosition+(own['head'].worldOrientation.col[AXIS]*RANGE)
            start = own['head'].worldPosition
            Ray = own.rayCast(end,start,0,'',0,0,0)
               ## cast ray to find grapple target
            if Ray[0]:
                    ##if Ray[0] = did you hit something? 
                if 'Enemy' in Ray[0]:
                        ## is it a moving enemy ?(a object with the property enemy) if it is he is your target
                           ## if the hit object is not a enemy grab the hit location rather then the enemy object as the target
            ## if own['Target'] is not a string then it is either a enemy or a vector
            Point = (0,0,0)
            ## to avoid issues with throwing a error
            if type(own['Target']) is not Vector:
                if not own['Target'].invalid:
                    Point = own['Target'].worldPosition
                    ## if the target is a game object and did not get deleted set you target as where the enemy is
                ## if the type is not a string (empty) or game object it is a worldPostion 
                Point = own['Target']
            if Point!=(0,0,0):
                VectorToTarget = Point-own.worldPosition 
                strength = 200
                max_speed = 20
                if own.worldLinearVelocity.magnitude<(max_speed):
                    own.applyForce((0,0,9.8),0) ## cancel gravity          

open file

press shift F

aim red line at ‘Static’ or ‘Enemy’

Enemy is a red cube with the property Enemy

Static is the white cube your not standing on

this is too shoot a grapple hook to a point, then reel in the player to that point

this combined with a ‘quit’ button


(cool down and quit)

could be used to make the actor fly almost anywhere, but will take skill.

also it counts on actually grappling from things.

having a ‘quit reeling and engage rigid body joint’ = hang from rope and swing from point

add in ‘kill rigid body joint’ =

you could grapple -> reel in -> swing and fly through the air, and then do it again a few seconds later=
spider man or attack on titan.


Grapple.blend (513 KB)

forgot logic in cool down

if EffectTime=end time------------------and-------------EffectTime=-120
_________________________________-------------Target = “Empty”


Grapple2.blend (519 KB)

THANK YOU! If the landscape was all one object, woould the character still zoom to where it points, or to the origin of the object? Also, where would one start learning Python for the BGE?

it only flies to the origin if the object is makred ‘Enemy’ using a property, however storing a local hit position would be better then the origin…

How dp I do that?
Also, how can I set up a parent between the p-layer and a certain object without using logic bricks for that specific object? So pretty much a parent between the player and an object it touches with a certain property. Sorry. I’m a beginner with Python fir BGE.

So, is there an edit that I can make to the script that will only let the player fall when the Shift F button is not being pressed?

shift------and--------9.8*mass Z

What kind of actuator would the 9.8*mass be? Or is it in the script? And what does the Z mean?

world Z, apply force, motion actuator,

that will cancel gravity

I’ll try and get to setting up the script so holding the button will keep you stuck ,
but I have a bunch to do, and not much PC time to do it,
(most of the time I am on my phone)

Actually, I switched the property sensor with the shift F bit, to Less than 130, and it did it by itself. Odd:eek: