Precise Tile Based character Movement. (W.I.P)

Ive been messing around with this in my spare time for about a week.

(blend file here, controls are arrow keys and enter key)

test.blend.zip (277 KB)

Im trying to create a game where the character is controlled on a grid based environment. he can only move in one of 4 direction based on camera alignment relative to the character up down left or right.

i wanted to be able to have complex level designs with turns and spherical surfaces so rather then just using an incremental movement system i have forced the character to snap to the location and rotation of the plane he is sitting on… giving the illusion of the character being locked to a grid but still being able walk on a curved looping paths (as seen in the attached blend file) which wouldn’t be possible with incremental movement.

the current issue im having is with the jump and double jump… the character should be able to hop one block high and one block in the direction he is facing… if in the air he can double jump to clear a one block gap and jump up an extra block higher or he can change the direction of his second jump mid air (as seen in the blend file)… the issue i am having is that this often isnt consistent… i have had to opt to use a dynamic physics motion setup up for jumps… this creates a jump arch i wanted but seems to have created another issue where the motion actuator is inconsistent in when it activates and creates instances where even though you double jumped you only go one block forward or if u had double jumped you go 3 blocks forward… so is there a way i can get a nice jump arch like physics provides and also have the character land constantly according to how man blocks he should be able to jump. i got most everything i want to be working as far as movement is concerned i just really need this to be accurate.

any suggestions to improve this setup would be appreciated. the blend file is really sloppy and messy because i have just been trying several ideas i have had to get things working… basically this blend file has been my doddle sheet… i will do everything over in a fresh blend file once ive figured out everything… appreciate any help and feed back. have a wonderful day!


I am making a gamewith tile based movement and my solution for movement and jumping is this:
When walking check the target tile, see if it exists and if it is walkable (not a higher or lower level, not occupied).
When jumping carry out the above check (slightly modified to take in to account the ability to move to higher or lower levels) but for each tile in a row extending in front of the character as far as they can jump. If a tile check fails, make that the furthest extent of the jump. The activate the jump.

The jump itself works by moving the box directly to the target square, while the armature performs a jump animation. This gives a nice parabola in the visual element (the player mesh) but avoids making the invisible part (the character box) move in a way that steps outside the tile based system.

I handle checks and collision through a dictionary of locations. If two objects share the same current location they can be assumed to have collided. During jumps collision is disabled, that’s intentional and introduces an extra gameplay element as you can jump to avoid damage, but you can’t exit a jump once started and jumping is rather slow.

this is what i had initially. but in favor of a jumping arch i tried what i have now… it worked alot better before aside from two things the character would automatically hit the ground once he lands on a space higher then the initial one… making double jumps awkward since you think you are still in your first jump… and i couldn’t increase how high he jumps because for some reason if the jump is set two high it starts to slowly move left relative to witch way he is facing… and i have no clue what could be causing that… might even fix itself once i start over fresh. but it looks like this is the why im gonna go.

your game looks like its coming along nicely btw.

how do you handle checks for movement from a logic perspective? … i tried using a ray sensor to look for objects ahead of the player with the property ground and then with a python script get the name of an object hit by ray then copy the player location and rotation to the tile detected… but this failed as i never figured out how to call the name of an object hit by a ray.

In python you can check;
If sensor.positive:
hit_object = sensor.hit_object
Or something similar…
You can find the exact terms in the blender python API.

-face palm- … oh you mean i could have used the Ray.hitObject function instead of trying to figure out how to get its name XD…why did i never try that!?!.. another case of me overthinking things i guess.

thanks man! with that i might not even need a motion sensor…
i can just put sensors above the tile to check if its there then copy its position to the player!.. thanks!

im still pretty weak in python but ive figured a lot out by just fumbling around in the dark…

if u have any suggestions for improvements im more then open to them… thanks for your time… have a wonderful day!