Spatial disappears when I move it

I’m facing a problem, this time it’s when I’m putting together everything I’ve learned and doing something, but this happened and it’s something that I was not scheduled for.

We have absolutely no idea unless you post some code :slight_smile:

1 Like

…especially and including the code that is printing your debugging output.

…because how is it possible that the spatial is moving with the camera when the values of it’s location aren’t changing?

Waaaaaaaaaaaay too much going on that we can’t see.

sorry kkkkk.

My wild guess, an NAN in rotation or position :slight_smile:

I do not believe … I do not believe that the problem can be this … in fact, I do not understand very well about the guartary rotation (x and z w).

Well, you didn’t output the rotation so we don’t know.

You will get more people to help if you find a way to include the relevant bits of code here without making us download and extract a zip. Maybe some folks will have the time but most won’t bother.

Thanks for the information … I will make the code available on the forum.

In case it’s necessary:

public void simpleInitApp() { super.flyCam.setEnabled(false); super.flyCam.setMoveSpeed(20); super.setDisplayFps(true); cam.setLocation(new Vector3f(disx, disy + 10, disz - 10)); cam.setRotation(new Quaternion(0.18495204f, -0.0086373165f, 0.0016255928f, 0.9827082f)); nod = (Node) assetManager.loadModel("Models/valet2.j3o"); spt = nod.getChild("2b02f008_obj");
    terr = new TerrainMaker(this);

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
    AnimControl cont=spt.getControl(AnimControl.class);
    deb=new SkeletonDebugger("mixanorig:Hips", cont.getSkeleton());
    Material mat=new Material(
    mat.setColor("Color", ColorRGBA.Blue);

    if (!flyCam.isEnabled()) {

public void onAnimCycleDone(AnimControl cont, AnimChannel can, String annome) {

public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
    // sem uso

public void initTeclado() {
    inputManager.addMapping("x-", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("x+", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("z-", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("z+", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("tab", new KeyTrigger(KeyInput.KEY_TAB));
    inputManager.addMapping("o", new KeyTrigger(KeyInput.KEY_O));
    inputManager.addMapping("l", new KeyTrigger(KeyInput.KEY_L));
    inputManager.addMapping("i", new KeyTrigger(KeyInput.KEY_I));
    inputManager.addMapping("k", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addListener(ac, "x+");
    inputManager.addListener(ac, "x-");
    inputManager.addListener(ac, "z+");
    inputManager.addListener(ac, "z-");
    inputManager.addListener(ac, "tab");
private final int velo = 50;
private float disx = 0;
private final float disy = 0;
private float disz = 0;

public void simpleUpdate(float tpf) {
    if (zma) {
        disx += tpf * velo;
        spt.setLocalTranslation(disx, disy, disz);
        cam.setLocation(new Vector3f(disx-10, disy + 10, disz));
        //spt.setLocalRotation(new Quaternion(0,90,0,1));
    if (zme) {
        disx -= tpf * velo;
        spt.setLocalTranslation(disx, disy, disz);
        cam.setLocation(new Vector3f(disx+10, disy + 10, disz));
        //spt.setLocalRotation(new Quaternion(0, 0, 0, 1));
    if (xma) {
        disz += tpf * velo;
        spt.setLocalTranslation(disx, disy, disz);
        spt.setLocalRotation(new Quaternion(0, 0, 0, 1));
        deb.setLocalTranslation(disx, disy+3, disz);
        cam.setFrustum(1f, 1000f, -0.6627417f, 0.6627417f, 0.41421357f, -0.41421357f);
        cam.setLocation(new Vector3f(disx + 2.4f, disy + 10, disz - 15));
    if (xme) {
        disz -= tpf * velo;
        spt.setLocalTranslation(disx, disy, disz);
        spt.setLocalRotation(new Quaternion(0, 0, 180, 1));
        deb.setLocalTranslation(disx, disy+3, disz);
        cam.setFrustum(1f, 900f, -0.6627417f, 0.6627417f, 0.41421357f, -0.41421357f);
        cam.setLocation(new Vector3f(disx + 2.4f, disy + 10, disz + 15));
boolean xma = false, xme = false, zma = false, zme = false;
private int a=2;
private int b=1;
private ActionListener ac = new ActionListener() {
    public void onAction(String name, boolean keyPressed, float tpf) {
        if (!flyCam.isEnabled()) {
            if (name.equals("x+")) {
                xma = keyPressed;
            if (name.equals("x-")) {
                xme = keyPressed;
            if (name.equals("z+")) {
                zma = keyPressed;
            if (name.equals("z-")) {
                zme = keyPressed;
        if (name.equals("tab")) {


Why do you call this?

cam.setFrustum(1f, 1000f, -0.6627417f, 0.6627417f, 0.41421357f, -0.41421357f);

I was making the camera spin when the character moves, so that the character does not escape the camera. Searching, I noticed that it was better to use this method than setLocalRotation (). But I can test using this method.

So, you need to make your camera look at the character?
Because if yes, there’s an easier way to rotate the Camera rather to creating Quaternions:

cam.lookAt(character.getLocalTranslation(), Vector3f.UP)

Or even better, learn how to use ChaseCamera, a 3rd person camera that, as the name implies, chases a specific spatial.

thanks, i whill try.

I’d also suggest printing the position/rotation values for the model as soon as you calculate them - that way you will immediately catch Float.NaN or other suspicious values.


I found this method very interesting but in fact it is not what I plan, but I was happy to know that there is something so easy, this will open up my horizons.

1 Like

I managed to solve … I’ll do a little tutorial about it … maybe it helps those who may have the same doubt, now or in the future …