Game Development Reference
In-Depth Information
if(walkDirection.length() > 0){
if(inCover){
checkCover(spatial.getWorldTranslation().add(walkDirection.multLocal(0.2f).mult(0.1f)));
if(!hasLowCover && !hasHighCover){
walkDirection.set(Vector3f.ZERO);
}
}
17. We add the current
walkDirection
vector to the position of the player and
check for cover at that position. If there is none, the movement is not allowed and
we set
walkDirection
to
0
.
18. Now all that's needed is a new mapping for
ToggleCover
, which is added to
InputAppState
:
inputManager.addMapping(InputMapping.ToggleCover.name(),
new KeyTrigger(KeyInput.KEY_V));