Location Lock In Game

I am making a side-scrolling game but my player glitches on sides of walls and moves on the x axis when i only want it to move on the y and z. is there a way to make the player not move on the x axis only in game?

Try locking the x translation in physics tab.



It is for dynamic and rigid bodys.

it still moves on the x axis. but only when i jump and move toward a wall.


import bge
cont=bge.logicGetCurrentController()
own=con.owner
if abs(own.worldPosition.x)>0:
    own.worldPosition.x=0


were do i put the script

in the item to lock on the axis,

this assumes that player is locked on 0 on X

text editor -> paste

always--------------python->script

that worked but now when i jump and i am touching the wall, the player doesn’t jump as high and also jumps back.

hmm

lets see a .blend?

runner.blend (586 KB)

use W A D to move and jump

I had some errors in the script,
also there is a strange Error linking controller" error


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    if abs(own.worldPosition.x)>0:
        own.worldPosition.x=0
main()




Is there a way to fix it?

Does that fix the player jumping back

I am not sure, I have never seen it before, i’ll look

yeah it fixes the player, but there is a odd error, that I have never seen

ok, it was empty expression checker I think

Attachments

runnerbpr.blend (586 KB)

but what about the jumping back is there a way to fix that?

So he cant go backward?

This locks his motion to and away from the camera ,

If you only want him to go one way… dont have that key?

no, when the player is moving forward at the wall/stairs and jumping at the same time. the player jumps back when not entended.
how do i fix that? tell me if i am not making any sense

Hi,
The reason your player bounces back is because of the motion actuator.
When you are pushing against a wall, it’s pushing your player 0.1 meters into the wall, and then when you release the key, it springs back out on the next frame.

This is more noticeable in the air because there is no ground friction stopping the player.
Try playing with the new “Character” physics type instead of dynamic. It seams to work very well.

Attachments

Simple Side Character Motion 2.70.blend (488 KB)

ya that works but is there a way to do that with a dynamic physics type because i am going to make it so that you can change the gravity and it doesn’t look like it follows the set gravity when using the character physics type. so is there a way around it doing that jump back? if not thats ok

You could set the Character’s fall speed when you set the world gravity. I believe the two values behave differently, but you could probably get it to work with some experimentation.