Third person 8 directional movement system

bge
upbge

(- Click for resources) #1

Hello,

You get the third person movement system (8 directional) including my keybindings script.

Added:

  • a converted version for UPbge (28-2-2019)

Controls:
K - open the keybindings menu
WSAD - move
SPACE - jump
mouse - lookaround
scrollwheel - zoom
left shift - run

BGE:
Tera movement system.blend (762 KB)

UPBGE:
8 directional movement system(upbge).blend (785.4 KB)

I hope you like it,
Cotax


Cotaks shared Bge/UpBge resources
Player movement relative to camera (a la Super Mario Galaxy) in UPBGE
Key and mouse bindings
(nilshaha123) #2

Wow that is really cool. Nice work. Can I make the player blend between the different directions?


(- Click for resources) #3
 Can I make the player blend between the different directions

Go to my_functions.py lookup face_direction(): and set turn speed between 0.0-1.0


(nilshaha123) #4

Ok, Thanks!


(Asdfghjkl) #5

Thanks again.


(sdhy) #6

What version of blender was this made in?
It’s having problems on 2.78 for me.
Thanks.


(- Click for resources) #7

in version 2.76 i thought it was, but this one should not give any problems, i am still using it myself (adapted version but the base it the same). What problems do you have?

Edit: and what version of blender do you use? it runs fine in 2.78a
Edit2: Runs fine in 2.78c as well


(Nick Manchul) #8

A good example and scripts, thank you! :yes:

Why do you use an additional object for the sensor “ground_chesk” and type - Collision? Is not it easier to create a “Ray” sensor on the player itself, or is it better to transfer it to a script?

Tera movement system-edit.blend (758 KB)

And when running through an external player, the player and camera are shifted to the right - 2.78с


(- Click for resources) #9

Why do you use an additional object for the sensor “ground_chesk” and type - Collision? Is not it easier to create a “Ray” sensor on the player itself

Everyone has its own way, but rays cast from origin, so standing on a ledge while the origin is not on it (so 1/3 of the player stands on a edge) the player will stop reacting because the ray wont get into positive state.

another reason, the movement feels heavier this way, while climbing and walking angles.

physics bunny hop problem is solved with the sensor as well look at here:

and here i solved the problem

some like rays, in this case you need rays to be cast from 5 points, center and 4 corners of the player, a sensor well you put it there and it works, not much work and look at tha last movie you see how it reacts to slopes as well, no flying etc just relaxed walking up and down, no bouncing either.

And when running through an external player, the player and camera are shifted to the right - 2.78с

the blend you uploaded has nothing wrong, works as it should here.

but if you got shifting problem i bet you moved the character, the camera is on slow parent, if you move it all cam settings will be off. in order to move em you select the camera empty go to objects tab in properties panel, scroll down to relation extras and turn of slow parent.


(- Click for resources) #10

Added:

  • a converted version for UPbge

(JakoNintenCraft) #11

Hi there. I’ve tried this setup with my game, and it works great up until planet gravity is added in. The player block just stutters and can’t move with the surface of the planet. I have a hunch it’s with the camera. Maybe change it so that it has the option to rotate with the player so that it can work with artificial gravity setups like mine.

If you want to troubleshoot this, my setup is as follows:

  • Make a new scene and go to the Scene tab. Set the gravity there to 0.

  • Paste the player setup into the new scene.

  • Add a new game property to the “player” object (doesn’t matter which type) and name it “gravity”

  • Add a UV Sphere below it. Make it static and give it a spherical collision box. Give it the float property “gAmount” and type in a number (this is the gravity constant, I use 9.8)

  • Add an “Always” logic sensor with true level pulse triggering and a “Python” actuator.

  • Make said actuator use this script:

from bge import logic
from mathutils import Vector

cont = logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()

for obj in scene.objects:
    if "gravity" in obj:
        
        pull = Vector(obj.getVectTo(own)[1])
        pull.magnitude = own["gAmount"]
        obj.applyForce(pull)

player = scene.objects["player"]
align = own.getVectTo("player")[1]
player.alignAxisToVect(align,2,0.5)

You should see that the player stutters erratically as it tries to walk around the sphere’s circumference.


(- Click for resources) #12

Hmm i see,
unfortunately i need to say this script is not compatible with planetary gravity.

The problem here is the calculation of the direction vector(where player needs to look at if you press a key) and the function face_direction() in my_functions.py, it also aligns the player to get his head back up.

uncomment that line in face_direction and set the vec_x and vec_y in player.py to own.blabla and if you press w it will act like you want but now you can’t rotate the player or set it’s direction anymore.

I suggest for now to try and use deadalus his setup, i believe he said it’s compatible with planetary gravity. I will look at this issue an other time and see if i can make it compatible.