physx-js-webidl icon indicating copy to clipboard operation
physx-js-webidl copied to clipboard

Cannot Use Character Controller Or Vehicles

Open AntoineUserName opened this issue 1 year ago • 4 comments

Hello, i need to use the Character Controller and the Vehicles but the classes just return an error:

new PhysX.PxController() and new PhysX.BaseVehicle() returns alls: "cannot construct a "class-name", no constructor in IDL"

I tried with the 2 different versions of physx-js-webidl and it's the same.

I have never used c++ before so if i need to compile the .wasm file i don't think i can do it.

AntoineUserName avatar Jul 07 '24 07:07 AntoineUserName

PxController and BaseVehicle are both abstract classes, you can't instantiate directly. For the character controller you need to create a controller manager first then create a PxCapsuleControllerDesc with the properties your controlelr should have. Then create the controller with the controller manager using your PxCapsuleControllerDesc. Something like this:

const scene = // create a scene first
...
const controllerManager = PhysX.PxTopLevelFunctions.prototype.CreateControllerManager(scene);

const controllerDesc = new PhysX.PxCapsuleControllerDesc();
// set controller properties to your liking, e.g. controllerDesc.set_height(1.5);

const controller = controllerManager.createController(controllerDesc);

The PhysX documentation might help as well: https://nvidia-omniverse.github.io/PhysX/physx/5.4.0/docs/CharacterControllers.html

For vehicle you have to create one of the subclasses of BaseVehicle. E.g. EngineDriveVehicle and then configure it as needed. However, in PhysX vehicles are pretty hard to set up correctly (There are a ton of parameters which need to be set correctly). So I would recommend starting with something simpler.

fabmax avatar Jul 07 '24 09:07 fabmax

Thank you, i tried but finally i don't think that the character controller is really for what i need.

I maybe need to use another physic, for the vehicles you recommanded me to use something simpler.

I searched and there is ammojs and cannonjs but idk which one are the most optimised and i need a good vehicle physic, this vehicle physic need a friction attributes and everytime i found a vehicle physic for these physics libraries the vehicle have no frictions. So basically i need a vehicle physic that allow the vehicles to drift.

Do you know an optimised 3D physic that you can recommand to me?

AntoineUserName avatar Jul 08 '24 12:07 AntoineUserName

I haven't really tried other engines, so I don't know how good they are but ammojs seems to be quite popular. There is also joltPhysics.js which looks pretty good

fabmax avatar Jul 08 '24 12:07 fabmax

I will test it, thank you

AntoineUserName avatar Jul 08 '24 13:07 AntoineUserName