ssatguru / BabylonJS-CharacterController

A CharacterController for BabylonJS
Apache License 2.0
215 stars 46 forks source link

updateTargetValue bug #53

Closed dad72 closed 2 years ago

dad72 commented 2 years ago

Hi,

There is a small bug in updateTargetValue.:

private _updateTargetValue() { //donot move camera if av is trying to clinb steps if (this._vMoveTot == 0) this._avatar.position.addToRef(this._cameraTarget, this._camera.target);

Something is missing when you want the avatar to look in one direction or another as well as the camera with a different beta and alpha and radius. Currently, my character can be anywhere on the terrain (it works on load), but the rotation of the character cannot be changed on scene load, nor can the beta, alpha and radius of the camera. If I save the position, rotation of the player and the camera, so that when the player reloads the game later, he finds the same position and rotation, it does not work. only the position is taken into account, but the player will always look in the same direction and the camera will have an alpha and beta and radius always the same.

put another way. If I want to rotate my character when loading the game, it does not work. If I make my camera with a beta, alpha, radius in one way, it is not taken into account. because the updateTargetValue function re-modifies my values. The character has a default rotation as well as the arcRotateCamera.

How to correct this? Thanks.

ssatguru commented 2 years ago

Hi @dad72 , In mode 0 the camera controls the rotation of the avatar and is also controlled by rotation of avatar. Try mode 1 and see what happens. To Change mode

dad72 commented 2 years ago

I don't use isometric. Mode 0 is what I need. I'm talking about the rotation of the avatar when loading the game which always looks in the Z position. (the camera is well behind the avatar in the third person.)

If I save the player's position and rotation in a database before he leaves the game and reloads the game, his rotation in Y is not taken into account (the position is taken into account, but not the rotation), the avatar always looks in Z regardless of the rotation values ​​saved. If I rotate the avatar to look south or west, when the game loads it will always look north by default.

I tried adding the rotation values ​​in the updateTargetValue() function and that fixed the problem, so I guess something is missing here. I also tried to remove this function in the call of the Start() function and that also corrected the problem.

I think something is missing in updateTargetValue()

Thanks

ssatguru commented 2 years ago

Mode 0 also has setTurningOff(true/false); So turn it off , change av rotation, turn it on ?

Further 4.4.3 alpha has following methods to help save and load the Character Controller settings getActionMap() getSettings() and setActionMap() setSettings() See get , set settings Try and let me know if that helps

dad72 commented 2 years ago

Ok, I updated to the latest version. I took the liberty of rewriting the class in jS ES6. Everything works with the update.

Thanks Ssatguru