Hi everyone!
Im having big troubles in trying to connect the first-person-controller.mjs script in a playcanvas react project. I want to use this script for the collision implementation of the camera basically. But it seems pretty outdated in relation with playcanvas react.
Do you have any suggestion on how to make it work, or how can i implement first person camera with collision in playcanvas react??
Any help is deeply appreciated:)
Thanks in advance!!
Hey @Jorgix Yep there was a discussion on the react GH last week about this.
@playcanvas/react lazy loads the physics and the FirstPerson script specifically depends depends on it, and errors if it doesn’t exists. We can probably improve that script to handle that better but for now, you can check on the physics state in react using the usePhysics hook and handle accordingly.
import { usePhysics } from "@playcanvas/react/hooks"
import { Script } from "@playcanvas/react/components"
import { FirstPersonController } from "playcanvas/scripts/esm/first-person-controller.mjs"
export function FirstPersonScript () {
const { isPhysicsLoaded } = usePhysics();
return isPhysicsLoaded && <Script script={FirstPersonController} />
}