Question

Hey people.

I made a W, A, S, D as forward, left, back, and right motions for a cube with mouse move for camera and cubes Z axis.
But many times i have played Quake3 and Quake2 and i have always been impressed by how these games are made control wise. Any ideas how to achieve or what needs to be added to make a cube move like that in terms of being able to make a strafe jump as far as i know is it called like that. As i understand there’s quite a lot to it cause for example in q2 if You travel at high speed from for example a rocket jump and if you release the movement WASD buttons it doesnt quite stop straight away. If i could express myself in other way for example in Fruityloops software theres a REL knob for envelope which makes release of the oscilirators tone button to have a tail whitch reduces the volume i guess slowly in time depending of the value of the rel knob.
I am guessing if it’s a case of making the forward location motion to decrease or increase after the button is being pressed and released.
And by the way any ideas what happens when a rocket explodes under your feet if you jump and pop one in order to make a rocket jump. Is it a rigid body ball that sizes up to make character being pushed back a bit?
Any thoughts or clues for me please?

I haven’t worked with BGE so far, but I’ll try to explain how you could approach this in general. This is just the idea, not a tutorial. I’m mainly an artist with limited coding experience though, so keep that in mind. There are most likely much better solutions.

Regarding the movement:
To be able to smoothly stop, you have to know how fast the player was before stopping. Not just the speed in general, but a vector3. Let’s call this your velocity. When you stop pushing the movement button, you want the game to still feed the last velocity vector into your movement while decreasing the vector length simultaneously to 0 over a short time.

Let’s say you’re running forward and slightly right, so your movement vector could look like this (200 400 0).
After a short delay it looks like this (100 200 0) until it finally arrives at (0 0 0).

Regarding the rocket jump:
You don’t need rigid bodies for this. At the time a rocket explodes, get all objects inside the rocket’s splash damage radius. First you should check if the splash damage is even relevant to them. Level geometry does not need to be informed about explosions. But players should be. Inside the player’s logic could be a function for physics explosions. So when a rocket explodes, it informs players inside the splash radius that a) they are inside the radius and b) how far they are away from the explosion center.

You can get distances between two objects with a very simple formula: get the vector3 position of your target (the player), subtract the vector3 position of your start (the rocket’s position) and get the length of that vector. That’s the distance.

The larger the distance, the smaller the applied force should be (because you are farther away from the explosion center). You also want to push your player away frow the rocket, so you need to know which direction that is. The formula is almost the same as the previous one: target - start, and this value normalized.

So you use the player’s position minus the rocket’s position and normalize that vector so it doesn’t exceed a length of 1.

Now that you know the direction from explosion to player and the distance between the two, you can add a physics impulse to you player with the direction you calculated and an intensity that’s stronger the closer you are to the center. This could work like this:

direction * 1/distance * intensityFactor

You can define the intensityFactor yourself. This just scales up how much you are pushed away. I used 1/distance so the value gets bigger when you are closer to the rocket and smaller when you are farther away.

1 Like

Ty 4 ur thougts but i think it seems too complicated for me to decode this.
Thing is i really liked Q2 and Q3 rocketjumps and i thought that it would be cool to come up with a spell for mage that would make an explosion and if he/she would jump by it then it would throw the character away in order to run away from a situation if player sees 3 or more opponent players in order to survive. I guess i will try to come up with some other way of how i think this could be done.

what @Sersch said is correct.

well an animation could be the piece you need to make a simple bounce away object.
add a sphere, make it the size of hmm. small. give it a scaling animation, small to big to small again.
Make this animation short like dunno 3 or so frames long (1 smal 2 big 3 small) now simply place it under the player and let it play the animation, it will bounce the player away. (you can see this effect at my pinball game, the bumpers are just that, animations that pushes the ball around).

but to be in control, you need python and the guide above.

→ Also why are you posting this in tech support, not the right section :wink:

Well i think its a bit techy innit? And i needed a bit of support so that i can keep me self occupied to come up with something cool for me project.

Ball should interract with character as a static object i suppose. And should contain some object in centre of it which would actuate the sizeup of the ball but set itself as a parent to a place of collision with the ground, tree or a wall if i am thinking right to make this to happen. But thats what i thought anyway, and You just encouraged me to try and test it. Cheers for that, so much on me mind.

you said it yourself “Well i think its a bit techy innit? And i needed a bit of support so that i can keep me self occupied to”

you need support, with the game engine so this is placed in the wrong section, you should have asked this in the game engine support and discussion topic, you will even find/get more answers there then here.

that would work, at my resources you can download my game(on bottom of page) you can see how i have done it, you won’t need something in the center of it, just add it below the player and play the action/animation, and it will push the player away

edit: sticky at top: About the Technical Support category

Oh well, for mod is just a click to move it to the right section. Its not like i killed someone.

Well 1 button? :stuck_out_tongue:

Yeah i know and i didn’t meant it in an offending way, just saying that you would get more support in the section where people actually using the game engine.

yes. i don’t remember the quake code, you can look it up yourself, but they use friction for the characters.

i’ve made some fps tests and move the players using force/inertia, and put a certain friction on the ground objects. i separated floor from walls, but in some cases leave an entire mesh as floor (stairs).

you also need to code that the player only moves when it’s over an object with a certain property (in my case “floor”), and jump with force as well.

as for the rocket it has to be done in python. something like:

import bge
cont = bge.logic.getCurrentController()
obj = cont.owner
scene = bge.logic.getCurrentScene()
objList = scene.objects

fz = 10.0

def explosion():
     mov_ob = [abc for abc in objList if "movable" in abc]
     if mov_ob != None:
          for ebc in mov_ob:
               vect = ebc.getVectTo(obj)
               ebc.applyForce[[vect[1][0]*fz, vect[1][1]*fz, vect[1][2]*fz], False]
explosion()

this script would have to run in the explosion object, and be executed once. fz is a multiplier of the force of the explosion. use a higher or lower value to move objects faster or slower.

edit: i don’t remember if blender has air friction, if not, it should be easy to code.

1 Like