Hello everyone. I have some problem while using walkDirection() method: spatial flies above the ground, how i can fix it? And one more question : how to rotate collision to viewDirection?
Here is a piece of code:
camDir.set(cam.getDirection());
camLeft.set(cam.getLeft());
pos.set(0,0,0);
if (forw){ pos.addLocal(camDir); }
if (backw){ pos.addLocal(camDir.negate()); }
if (left){ pos.addLocal(camLeft);}
if (right){ pos.addLocal(camLeft.negate());}
if (jump){if(this.onGround()){ jump(new Vector3f(0, 25, 0)); }}
pos.multLocal(25f).multLocal(tpf).normalizeLocal();
setWalkDirection(pos);
setViewDirection(camLeft.negate());
Normalize will kill all of that, so it has to be after pos and before mult. That would mean you have a speed of 25m/s resulting.
Flying also sounds like you need a .setY(0f) in the Walk Direction.
Setting the ViewDirection on pos.normalize() (not local!) looks into the walk direction.
or he might need set gravity properly for BetterCharacterControl.
there could be many reasons. about pos, i see he normalizeLocal it seems fine for me, well i agree its wrong having it at the end or why it is there, but should work anyway, just not related to having Spatial in air imo.