A example of some pretty niffty math JetPackCharlie

A example of some pretty niffty math , and a finite state machine

JetPackCharlie

WASD

Attachments

JAtPAckCharlie.blend (453 KB)

Attachments

JAtPAckCharlie2.blend (501 KB)

Feels like he would be flying in reality, but he doesn’t feel real:D The mechanics are cool, but the box shouldn’t fly like that basing on physics. Unless it has very strong and lightweight engine in it and it is made itself of kinda graphene material:D

yeah, I made it in 22 minutes.

:smiley:

Wow… Usually it takes about 20 minutes for me to setup scene for game(lighting, enable GLSL and game engine, set resolutions, remove useless stuff etc.)

Nice work! this is great :smiley:

How about setting up blender for game making and then press CTRL-u to save your default setup?

@BPR
It looks great, a nice flying demo.
It might be good to write a single function though rather than all those if statements.

I usually do things like that with a function and a dictionary:


import bge
import mathutils

def flying_demo(cont):
    own = cont.owner

    def fly(control,own):
        directions = {"left":[-1.0,0.0,0.0],
            "right":[1.0,0.0,0.0],
            "forward":[0.0,1.0,0.0]} #etc...

        own.worldPosition = own.worldPosition.copy() + mathutils.Vector(directions[control])

    control = "left" # get control direction from sensors or from another dictionary
    fly(control)

That way you only need one function and one dictionary which change behavior as you input different control arguments.

Defining your variables in a dictionary like this also makes it easier to keep track of them, change them, and even customize them, as you could redefine the dictionary.

yeah, like picking up a powerup changes the dictionary out for a new one?

I need to get into using functions and classes,
I know how, but I just dont need them most of the time.

Cool use of vectors! Reminds me of the jetpack portions of Pilotwings for the SNES.

I have a question: I notice a lot of your scripts use this…


own.alignAxisToVect(rot<i><i><b>.col[0]</b></i></i>,0,.05)   

What is that? I’ve tried to look into it, and the only other examples I see of this bit of code is when dealing with vertex colors (‘col’ = color?), but your use of it doesn’t seem to have anything to do with color? I am curious.

Column ,

worldOrientation.col[0] = objects x axis

.col[2] = objects Z axis

-object.worldOrientation.col[1] = -y axis.

check this out

this places a object at x axis +10 without calling import vector,

Attachments

Checkit (2x).blend (452 KB)

Ah, I see now. That is a cool little trick!

Nice minimal visual effect too! Here’s a full-screen test video: