BabylonJS / BabylonToolkit

Home of the community maintained Unity & Unreal exporters for Babylon.js
174 stars 46 forks source link

Missing Some System Components #26

Closed fenos closed 3 years ago

fenos commented 3 years ago

Hello there! Thanks a lot for this amazing plugin.

I was scanning through the documentation and there are quite a bit handy scripts that come with the plugin.

I was specifically interested in the CharacterComponent but it doesn't appear in the dropdown as well as few other mentioned in the doc. Any idea?

image

MackeyK24 commented 3 years ago

It now uses the native Unity Character Controller component... And the BABYLON class you use is BABYLON.CharacterController

const controller = this.getComponent("BABYLON.CharacterController");
if (controller != null) {
     controller.move(velocity);
}
fenos commented 3 years ago

@MackeyK24 Ahh thanks a lot for that!

I've played around with it and it's very nice! However, i've noticed something very weird (probably i'm doing something wrong) maybe you can help.

As soon as I add the CharacterComponent to a 3D capsule when the game load I see the capsule being under my map level.

I'm not sure why at this stage, but it could either be that the map load after the character is spawned and the gravity is pushing it down. Or I'm not sure what's going on.

Here is what's happening:

image

When the game Load:

image

Both the capsule and the world have collisions

MackeyK24 commented 3 years ago

First of all... you have both a capsule collider and a character controller on the game object. You dont need both. You EITHER use a capsule collider and normal rigid body physics to move you game object around with setLinearVelocity.

Or

You use the Kinematic Character Controller to move you game object around using the controller.move function.

In either case there is a Center property on the both colliders... you need to use that to offset the the collision fopr the game object... Try putting in 1 in the Y for the center... That should offset the collision mesh... You should be able to see this in the Unity scene before you export

...

If you still cant get working... send me the scene ill will fix it up and show you whats the what

fenos commented 3 years ago

@MackeyK24 I see! that did the trick! Apologies for my newbie question. Is there a way for me to contact you privately please, I'd love to ask you a few questions about the toolkit and general best practices

my email is: fabri.feno@gmail.com

i'll be happy to share the scene