(Solved)Vector won't change when I use .add()

Hi all. Basically, I’m trying to change a vector from a different thread.

I set it up newVector=new Vector3f(); so it’s set to 0,0,0
Then I call this method from another thread, along with my inputs to change the x and y fields by:

public void changeView(float xa, float ya){
                System.out.println(newLoc);
                System.out.println("XA: " + xa + ", YA: " + ya);
                Vector3f addd = new Vector3f(xa, ya, 0);
                System.out.println(addd);
                newLoc.add(addd);
                System.out.println(newLoc);        
    }

The first system.out returns: 0,0,0
The second system.out returns my values I input
The third system.out returns the correct Vector3f
However, the last system.out STILL RETURNS 0,0,0 so that means it’s not adding it or it gets reset?

I even tried to enqueue it, yet that didn’t work either:

public void changeView(int dx, int dy, final float xa, final float ya){
        this.enqueue(new Callable(){

            public Object call() throws Exception {
                //newLoc=cam.getLocation().clone();
                System.out.println(newLoc);
                System.out.println("XA: " + xa + ", YA: " + ya);
                Vector3f addd = new Vector3f(xa, ya, 0);
                System.out.println(addd);
                newLoc.add(addd);
                System.out.println(newLoc);
                return null;
            }
            
        });
        
    }

I’m rather confused and I’ve spent a lot of time trying to get this stupid thing to work… Any enlightenment as to how I can get it to work?

Thanks.

Hi, I think you want to use addLocal instead of add.

3 Likes

Well.
Guess I’ve been away from jMonkey far too long…

Thanks >.< noob mistake wow, how embarrassing…

2 Likes