YANQ – Yet another noob question. Strange stuttering when going against wall

Basically camera and CharacterControl, since camera is attached to it, jumps up and down by few pixels (5-20 is the amplitude) when I’m going against wall, or even when I’m standing in room. How to minimize or remove this stuttering?



Player code:

[java]CharacterControl player2 = new CharacterControl(capsuleShape, 0.07f);

player2.setJumpSpeed(20);

player2.setFallSpeed(30);

player2.setGravity(30);

player2.setPhysicsLocation(playerLoc);

CapsuleCollisionShape caps = new CapsuleCollisionShape(1.1f, 0.7f, 2);

player = makePlayer(caps);

[/java]



Actual movement:



[java]if(isEnabled()){

//speed Multiplier is there because otherwise player would move too fast

float speedMultiplier = 0.4f;

Vector3f camDir = cam.getDirection().clone();//.multLocal(speedMultiplier);

camDir.x = camDir.xspeedMultiplier;

camDir.y = camDir.y
speedMultiplier;

camDir.z = camDir.z*speedMultiplier;

Vector3f camLeft = cam.getLeft().clone();//.multLocal(0.4f);

walkDirection.set(0, 0, 0);

if (left) { Quaternion lft = cam.getRotation();

float[] angles = lft.toAngles(null);

angles[1] = angles[1]+tpf;

lft.fromAngles(angles);

cam.setRotation(lft);}

if (right) { Quaternion lft = cam.getRotation();

float[] angles = lft.toAngles(null);

angles[1] = angles[1]-tpf;

lft.fromAngles(angles);

cam.setRotation(lft);}

if (up) { walkDirection.addLocal(camDir);// System.out.println(“up”);



}

if (down) { walkDirection.addLocal(camDir.negate());// System.out.println(“down”);

}

player.setWalkDirection(walkDirection);

cam.setLocation(player.getPhysicsLocation());

} else {

// do the following while game is PAUSED, e.g. play an idle animation.



}

}[/java]



Don’t suggest me changing capsule collision shape though - been there, done that. Resulted with player being able to see through walls when standing on certain angles. And yes, you right - game does NOT have muse look. It’s oldschool raycaster-like game, though rendered using OpenGL ;).

Just stop moving against the wall, easiest solution. Also the stepheight parameter in the character constructor is a bit low.

Well, I can stop moving against wall, but I’m not responsible for players ;). And thanks, I’ll try to increase step size.



//edit: Didn’t work, it even increased visibility of the problem.

@dariuszg-jagielski said:
Well, *I* can stop moving against wall, but I'm not responsible for players ;).

But you code the application and set the walkDirection.
Edit: Oh and is the wall basically just a huge quad and has a triangle size much bigger than the characters size?

Think!



Test if the character’s movement will hit the wall. If it does, consume the input, the forward movement (keeping the angle so it can slide in the angle while sliding along the wall), or whatever.

If I would know how to do that… Because now it’s either stopping and discarding angle (by shooting ray from camera and checking if player is close enough from wall to constitute stopping) or stuttering (like it is now).



Normen, yes, it is big quad, bigger than player. Basically I’m making labyrinth game which looks like Wolf3D. You have to find red gemstone in it. So no slopes, only flat floor and ceiling (which will be textured too as opposed to wolf3d) and walls.

Well that could be a reason then.

Does it effect the shaking issue if the player has to find green gemstone rather than red ?

So what course of action do you suggest?

I read through your code, and I don’t see any collision detection or collision response calculations.



Are you colliding a bounding box against a triangle mesh? From what I understood you are working on a Wolfenstein3D kind of game, right? Which means that your collision detection could be far simpler than a box / triangle collision, you could simply evaluate your players position inside the bitmap “maze” and use a hard constraint to prevent him from penetrating walls - making in a simple 2D problem rather than a 3D problem.



I don’t know what kind of physics / collision response you are using, but shaking is common in physics when you use soft constraints ( A force depending on penetration to push the object back. ) A hard constraint would be a better collision response for a wall. A hard constraint for a floor could be:

[java]

if ( pos.y < 2 )

pos.y = 2;

[/java]

For a wall this would very similar.



Hope it helps…

1 Like

Well, Player’s ControlCharacter is standard CapsuleControlShape as in tutorials (Hello Picking). Tried to use BoxCollisionShape, but gave up after seeing many NullPointerExceptions.

@dariuszg-jagielski said:
Well, Player's ControlCharacter is standard CapsuleControlShape as in tutorials (Hello Picking). Tried to use BoxCollisionShape, but gave up after seeing many NullPointerExceptions.

Lol, everything in that sentence is wrong and NullPointers are the easiest issue to track (and most probably root in your own code).

sigh :facepalm: