Jump like spyro

I am trying to make a character that jumps when you hit X and glides if you hit X again before touching the ground. (yes, exactly like Spyro the dragon 1

What I’ve got so far is:

-If X is hit then the a tap force of 100 is applied for 1 game click launching him off the ground
-If X is hit and character is still off the ground then it enters another state where there is a constant Y force and a little Z force (to slow down the falling) is applied.

Here is where the problem begins. I am bad at describing it with words so I’ll use pictures!
http://i77.photobucket.com/albums/j50/Saffrah/JUMP.jpg
The Green Line Represents the path the character follows when X is pressed at the top of the jump

The Blue Line Represents the path the character should follow when X is pressed at the middle of the jump

The Red Line Represents the path the character really follows when X is pressed at the middle of the jump

Notice how the red and the green lines come to the same height.

I know what is causing it, the velocity from the initial jump is continuing through to the next state. So maybe if I can find a way to freeze the velocity where it is? Or would it be practical to temporarily turn the character from a dynamic object into a static object until it touches the ground?

Does anyone have any ideas on how I can fix this? I don’t HAVE to use force for the initial jump, I’m sure there a better option out there I just don’t know about it due to inexpierince

you would have to use a invert-motion function (not included in the BGE)

here is one i use.

def StopMotion(self):
    
        motion = self.getVelocity([0.0, 0.0, 0.0])
        inversmotion = [motion[0]*(-100),motion[1]*(-100),motion[2]*(-100)]
        self.applyForce(inversmotion, True)
        
        return inversmotion

greets Equal

PS: in the game project YO Franki! he slides also mb you can view there for some informations.

thank you Equal. I have never used python scripts before, just the logic bricks. I typed in that script you gave me into blender’s text editer but I am at a lose of what to do from there. I know I have to some how apply it to the game engine logic bricks through a python controller… But from what kind of sensor and to what kind of controller do I connect it to?

any object can hold the controller, there is less a difference on where it is better placed, it is most only a question of organisation.

so you need to connect all sensors to that controller that holds the script.

then at specific conditions you use this function like this

if IsInAirCondition == 1 and buttonJump.positive:
    StopMotion(OBJECT)

this holds the object at its place and removes all motion to it.
You would then have to apply some other sort of motion to let is move forward.

Here is a nice site, i have linked it and it helps me dealing with my everydayBGE.
http://www.tutorialsforblender3d.com/

greets Equal

thanks for the link and the advice it will definitely help in the future. :slight_smile: I found another really old thread that helped me solve this particular problem in a primitive yet effective fashion :yes:

http://blenderartists.org/forum/showthread.php?t=681