New version of Character Controller (0.4.1)

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 )

Demo
Document
Release

14 Likes

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.

2 Likes

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 :slight_smile:

2 Likes

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

1 Like

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 :face_vomiting: :older_adult:

1 Like

@Dad72 I didnā€™t know about FollowCamera. I should have guessed itā€™d been done in BabylonJS already :slight_smile:

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:

1 Like

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.

1 Like

Awesome :smiley:

1 Like

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.

@withADoveInOneHand
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 :slight_smile:

Awesome thanks!

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)?

1 Like