Character control questions

Is this the rightrecommended way to adjust the movement speed for character there seems to be no explicit way to do it…or am I missing it due to how its named:

[java]walkDirection.addLocal(camDir.multLocal(speed factor))[/java]



and how do u get the jump to retain the directional momentum or a portion thereof even if you release the movement key while the character is in the air. if u release the movement key the character simple falls straight down



each charactersobject can have there own gravity right is it safeadvisable to play with that in real-time and if so is it possible to have something like a gravity vector for the character control, I see there isn’t one, I’m thinking it might be a nice “easy” way to have character appear to walkstand on walls and ceilings or are there drawback to that.



thanks in advance

why dont the forums like back slash :?

no, bullet is framerate independent, just set the length of the vector to the desired speed and leave it there. as i said multiple times in all the “wtf character??” threads, the character is no real physics simulation, so you can set any values.

normen said:
just set the length of the vector to the desired speed and leave it there
um could u elaborate, psuedo code or something, looked up character control methods but could come up with nothing other than what I did there is [java]walkDirection.set(0, 0, 0);[/java] but changing that cause the character to fly off to parts unknown

. as i said multiple times in all the "wtf character??" threads, the character is no real physics simulation, so you can set any values.
which means :? .......... its there you just dont look hard enough................or it can be done, figure it out and add it yourself

Ultimately epic line of code incoming:



[java]moveDir = some_vector_you_specify_dependent_on_buttons_people_press___Z_is_WS_X_is_AD;

if(player.onGround()); // Don’t change walk direction if not on the ground

player.setWalkDirection(cam.getDirection().mult(moveDir.getZ()).setY(0.0f).normalize().add(cam.getLeft().mult(moveDir.getX())).normalize().mult(moveSpeed));[/java]



moveDir.getZ() and moveDir.getX() simply contain 1 or -1 depending on the buttons pressed.

setY(0.0f) is used to get rid of camera up/down angle, we want to walk forward, not up into the air or into the ground

normalize() (first) is used to get the total length of this resulting forward vector back at 1.

normalize() (second) is used to make the total resulting vector have length 1 so total movespeed is not increased if a guy walks diagonally.

mult(moveSpeed) makes the total movespeed dependent on the value of moveSpeed, so you can walk slowly more easily when needed.



I can imagine it’s a tad difficult to come up with that…

Enjoy :wink:

thanks for this do u know of a way to apply gravity as a vector rather than a single float that always assumes Y as the axis

its not possible