Just released a new version of Character Controller for Babylonjs.
Summary of change
- added support for both front and back facing characters/avatars
The previous controller expected the character mesh to be created and animated facing the negative z direction. In other words, in rest pose, the character was expected to be facing the negative z direction. Now it supports both front and back facing characters.
- added support for top down/isometric kind of use cases.
The previous controller was good for third person or first person type of games.
It was not suitable for top down or isometric kind of games where the camera follows but does not rotate the character or rotates when the character rotates. Now it supports both type of games.
- added support to control character movement via script
Previously the character could only be moved via keyboard. Now it can be moved via script too. This makes it easy to add support for devices like touch joystick or “move on mouse click” or UI etc
- fixed glb character strafing issue
- code cleanup (@dad72 )
Delighted to have helped, contributed and tested from all angles this rather complete project to move a character without physics while simulating it a bit.
I recommend this CharacterContoler which works well.
Looks great! Thanks @satguru and @Dad72.
One feature suggestion would be to add optional or configurable easing on third-person camera moves. I’ve always found it quite jarring in third-person games when the camera tracks avatar orientation precisely and instantly rather than gently following with easing (like say a drone camera might in the real world). For FPS games I can understand the need for responsive, precise movement, but for many other use cases, especially for spectators rather than players, gentler movement is more enjoyable (less nausea inducing) IMHO
Are you talking for example about a camera that bounces when a character jumps, it lands on the ground and the camera performs a small bounce?
I find this idea cool. I was thinking about doing that.
Let’s see what Satguru thinks
I hadn’t thought about jumping, but I guess it applies equally to that scenario.
I was thinking mostly about turning/rotating the avatar - the camera could follow with a delay or accelerate and catch up to avatar orientation.
Ah yes, ok, yes that would be cool too. There is a camera like that in Babylon, the cameraFollow I think, but it’s a freeCcamera, for the character you have to use an acrRortateCamera, but it must be able to do that too
On a side note, I used to really enjoy FPS games like DOOM, Quake, Half Life etc when I was a kid, but I bought DOOM Eternal recently … and it was too much for me. I think I’m getting too old for FPS games
@Dad72 I didn’t know about FollowCamera. I should have guessed it’d been done in BabylonJS already
Lol, yes that’s its name: FollowCamera. She has been around for a while. I used it once to try it, but on a character, it was very complicated, because it is not an arcRotateCamera. I suddenly dropped it.
Looks like there’s 2 variants:
Oh, I hadn’t seen that. This is good news, I’m going to have to give this camera a try again. Thanks for letting me know.
That should be doable. Would look into it.
@inteja A little camera lag is always welcome. I’ve also found that a camera that points directly at the character at all times to be a mite undesirable.
Very cool character movement demo. There’s some combos missing I’d like to see (like run + backwards), very interested in the skele. Looks good.
Well after giving arcFollowCamera a try, this will create a bug because the folllow camera needs a target and CharacterControler already creates a target to follow. I think there is a conflict or something else. Anyway, it works well with a normal arcRotateCamera, so the camera acceleration and bounce effects have to be added directly in CharacterControler.
About the missing combos
I debated with myself about that . Should there be a back run? What about side run?
Some character controller turns the character around on back key and turn them to side on strafe keys.
Maybe have another mode?
The mode I implemented is more like the “minecraft” kind of mode.
As far as skele is concerned you can find all the original blend files here
The mesh is from Mixamo. Forgot where I got the skeleton. SecondLife maybe. Animations are a mish mash. Some from here, some from there
Yeah backwards and strafe running were what I wanted to see. I like that ‘mode’ where the character just turns and runs the direction of the strafe, but I also like plain faster strafing/backstepping (it’s very lifelike)… Actually a strafe-run before transitioning into ‘turn that direction and run’ would probably be the ultimate. [like saunter-strafe into fast strafe into turn and run and sprint ;p]
Doesn’t turn left/right button + forward/backward give you the same functionality?
Not sure. I’ve been rebuilding my project so I’ll be revisiting this soon. It’s definitely a fine balance that must be achieved between the camera and player movement.
My only gripe with this excellent demo is strafe and forward/back being exclusive.
Hi, is it possible to allow the character to move while in the air (eg, still have control, at the moment when you jump you can’t effect movement until you land)?