[Solved] New to jme3, and experiencing weird behavior

And I realize that even then I left some ambiguity in… so please paste the code that works with a simple change and doesn’t work by reversing the simple change… and please include a pointer to what the simple change is (a comment or whatever).

And by “post the code” I don’t mean put it on github, I mean paste it into a code block here.

Debugging is about knocking down assumptions. When we have to assume everything then we can debug nothing.

Some quick questions:
Why doesn’t your cleanup() method do any clean up?
Why are you saving your game as an input listener?
Why are your package names in CamelCase?

It looks like a .NET namespace I would expect your root package to be com.robbi_blechdose.rpg

Did you mean to create a player object twice?

if(player == null)
player = new Player();
player = (Player) SaveGame.loadGame("Steam/Saves/", "Player.sav");

I think you meant to do this

player = (Player) SaveGame.loadGame("Steam/Saves/", "Player.sav");
if(player == null) {
	player = new Player();
}

Also you should look at changing your player object to a Control. And maybe your save object should only contain the data your needing to load your game.

I did notice in your Player object read method the following…

public void read(JmeImporter im) throws IOException
{
	InputCapsule in = im.getCapsule(this);
	
	this.firstPersonCam = (FirstPersonCamera) in.readSavable("FPCam", new FirstPersonCamera());
	this.thirdPersonCam = (ThirdPersonCamera) in.readSavable("TPCam", new ThirdPersonCamera());
	
	// don't you need to attach this to the physics space you will?
	// or you could just create a new one like you did in init, but you should still add it back to physics space.
	this.playerControl = (BetterCharacterControl) in.readSavable("PlayerBCControl", new BetterCharacterControl());
	this.playerNode = (Node) in.readSavable("PlayerNode", new Node());
	this.playerNode.setLocalTranslation((Vector3f) in.readSavable("PlayerPos", new Vector3f()));
	
	// shouldn't you add the thirdPersonCam back to the playerNode here?
	this.playerNode.addControl(this.thirdPersonCam);
	
	this.chaseCamOn = in.readBoolean("ChaseCamOn", false);
}

To sum this up your controls arn’t attached to your playerNode, and your character control is not in the physics space.

@Robbi_Blechdose I hope my above post doesnt come off as me being rude. I might be wrong about the spatial being attached to the controls though I now see you have removed the if null statment above your player.init method call. I would suggest reading the source on SaveGame and all the base classes you are trying to implement.

By the way great start can’t wait to see your progress on this in the future.

Thank you. :smile:
I decided on rewriting some parts of my game and found lots of other mistakes I made.
As soon as I have them corrected, I’ll follow your advice (which will probably be in like two hours or something :wink:).
Again, thank you very much for the help. :smile:
By the way, I should call my players init() AFTER loading the save, right?

@pspeed
It didn’t work, I only got the same bug with the flyByCam.
And why isn’t git OK? It is even possible to log into the forums using a git account…

Robbi Blechdose

Git is fine just post the source snippets you need help here in a code block so we don’t need to go digging throughout your project to help you.

OK.
So, I made some changes and the physics work, just this camera problem persists.
The new version should be on git any minute now.
It’s too much to post in snippets.

Robbi Blechdose

Because GIT requires me to jump around a bunch of links and make 100 assumptions about what I’m supposed to be looking at. Assumptions = bad… because debugging is all about eliminating assumptions not adding to them.

You said you had a simplified case that worked and didn’t work with the movement of one line of code. How am I supposed to find that in github? Why is it so hard to type three back ticks (`), paste the code, and type three more back ticks?

And what camera input are you questioning the third person or first person?

@Robbi_Blechdose if you didn’t see this How to get answers

Both inputs,
because if the cam is wrong on first person, the same happens to third person.

@pspeed
Either I said something wrong or you read something wrong, but I never meant that I had an example without the camera bug.
BTW: The classes where I think the problem could be are: src/Camera/FirstPersonCamera and ThirdPersonCamera, src/Entity/Player and src/Main/GameStates GameState and GenericState.

Robbi Blechdose

So, yeah, I don’t even know what this means.

Anyway, good luck with your game.

I finally fixed it!
YAY! :smiley:

I had to set the initialUpVec in both cams to 0, 1, 0.

Robbi Blechdose