It’s using the BetterCharacterControl, it doesn’t have that method… (Actually it does, but it’s protected… and I would make an class that extends it, but I don’t think it was meant to be done that way, and will cause issues…)
I think hes saying that setWalkDirection() overrides warp() because they both end up calling the same internal function.
Kind of like how spatial.move() is an alias for spatial.setLocalTranslation(). You should probably try a fresh project and try your code out. I just set up the same sort of thing and didn’t have an issue.
Yeah, this behavior is weird…
I recommend testing it on a fresh project as well.
Maybe you have some code setting the node to (0,0,0) somewhere hidden…
I use BetterCharacterControl all the time and it works fine.
Also when you have a little, fresh project, you can easily send us all of the source code.
Well, I’m glad to announce to you…
The player spawns and gets teleported to (2, 35, 2) and starts falling.
If you wanna move the node, you need to add something like
to the simpleUpdate method.
If you wanna move the player through keys, you need to add the mapping to the input manager, calculate the appropiate walking direction and apply it.
This is an object that manages the a player
public class Player
// Our boolean variables for movement
public boolean forward = false, backward = false, lStrafe = false, rStrafe = false;
// Temporary vectors for moving the player
private Vector3f camDir;
private Vector3f camLeft;
private Vector3f walkDir;
private Vector3f loc;
// The camera that this player can see
private Camera cam;
// The actual player object
private BetterCharacterControl player;
// The node that manages the player
private Node playerNode;
This is the constructor, it is in charge of initializing default values
@param cam :: The camera that this player uses
@param Bas :: BulletAppState, used for incorporating physics
public Player(Camera cam, BulletAppState Bas)
// Initialize vectors now to save time later
camDir = new Vector3f(0,0,0);
camLeft = new Vector3f(0,0,0);
walkDir = new Vector3f(0,0,0);
loc = new Vector3f(0,0,0);
// Store the given camera
this.cam = cam;
// Setup global character properties
player = new BetterCharacterControl(.9f, 1.9f, 1f);
player.setJumpForce(new Vector3f(0, 0, 0));
player.setGravity(new Vector3f(0, -10, 0));
// Attach the player and give it physics
playerNode = new Node("Player Node");
// Initialize to default location
player.warp(new Vector3f(2, 35, 2));
This is the update sequence, it
Manages the walking behavior
@param tpf :: The time per frame
public void update(float tpf)
// Establish camera directions
// Reset walk direction, and fix a camera direction issue
camDir.y = 0;
// Set the walk direction
// Setup the camera to match the walk direction
loc.y += 1.5;
Makes the player jump
public void jump()