effect:
maybe low fps? or how to make smooth movement of the model behind the capsule?
model disappears and then appears elsewhere.
effect:
maybe low fps? or how to make smooth movement of the model behind the capsule?
model disappears and then appears elsewhere.
solved bad video card :
In my experience you have this issue with low fps when you update the camera position in update() instead of render(). I just wanted to point that out in case it happens again.
THANKS.
But what different between render and update?
I need update camera in render method?
Ind what need do in update method?
example pleas… thanks
render() is called before the rendering of the scene, update is called after.
If you are using an AbstractControl you have to override controlRender(RenderManager,ViewPort), if you are using an appstate you have to override render( RenderManager ), if you are updating the camera from a SimpleApplication instead, you have to override simpleRender(RenderManager) . That’s it, you move the camera update from your update/controlUpdate/simpleUpdate method to one of these.
The idea is: if the position is updated in the update() method, you are always one frame behind.
Understand.
This:
camDir.set(cam.getDirection()).multLocal(0.3f);
camLeft.set(cam.getLeft()).multLocal(0.2f);
Vector3f location = new Vector3f(players.get(localPlayerId).characterModel.getWorldTranslation().x,players.get(localPlayerId).characterModel.getWorldTranslation().y + 2f,players.get(localPlayerId).characterModel.getWorldTranslation().z);
cam.setLocation(location);
insert in render?
yes
Need add to render other methods…
What happen in render?
If I override it
That’s a java question, read the official documentation if you are not familiar with overriding a method.
Work very good.
public void simpleRender(RenderManager rm) {
if(players.get(localPlayerId) != null){
camDir.set(cam.getDirection()).multLocal(0.3f);
camLeft.set(cam.getLeft()).multLocal(0.2f);
Vector3f location = new Vector3f(players.get(localPlayerId).characterControl.getPhysicsLocation().x,players.get(localPlayerId).characterControl.getPhysicsLocation().y + 2f,players.get(localPlayerId).characterControl.getPhysicsLocation().z);
cam.setLocation(location);
}
}
update is also called before the rendering of the scene… but simpleUpdate() and appstate.update() are called before the controls have been updated. So if you sync the camera to a spatial on simpleUpdate() then you miss the changes that are about to happen in its control.
Edit: this was in response to @RiccardoBlb’s assertion that update happens after rendering. From a certain perspective, that’s true… but then render happens after render, too. In one update pass, update is called first… then the control updates… then render.
So I have to return this part of the code to update?
Vector3f location = new Vector3f(players.get(localPlayerId).characterControl.getPhysicsLocation().x,players.get(localPlayerId).characterControl.getPhysicsLocation().y + 2f,players.get(localPlayerId).characterControl.getPhysicsLocation().z);
cam.setLocation(location);