Open Slluxx opened 11 months ago
Nice, but what about the transform-origin/camera position bugs?
Right. I couldn't find any camera bugs in my testing, but the transform origin definitely is a problem. I don't exactly know how to fix that.
Sadly i dont know a solution to that either. All i can come up with are hacks that will have undesired effects. The cleanest hack i can come up with on the spot would be to save the height of the player and apply it while the size is changing. When jumping it doesnt really matter i guess cause it will make you just jump "slightly higher", but when on the ground, it would glue you to it.
The camera bug i only noticed when changing
var base_player_y_scale: float = 0.95
var crouch_player_y_scale: float = 0.45
To make the player fit under 1 standing and .5 crouched.
Multiple Things i noticed
Crouching transforms the body and collision from the center, which sometimes (more often than not) causes the player to float due to its shrunken size and then drop to the ground. I dont know if its possible to change the transform origin to the bottom of the player or if a different solution has to be found.
It also causes the camera to glitch into the body but i think thats because the distance the body shrinks and the camera moves is different.
Being crouched and releasing the key while being under something with a collision should stop the transform process back to normal until enough space is available. This can be done using 1 (or more if more presicion is needed) RayCast3D Node(s). Currently, the code doesnt check this and it will either stop the player from moving at all or cause other bugs.