I want to make a game that the player can move in a 3d space model. When clicking the floor, the player can move to the point with constant speed, and he can not pass through the wall.
Here is the demo I’ve made: https://playcanv.as/p/Mq9bG9Yd/
Here is the project: https://playcanvas.com/project/485551/overview/house-scene
But I have trouble about moving the player(camera).
As you can see, the camera can rotate normally, but when you click the floor, though the camera can move to the point, the viewport reseted unexpectly.
When the camera collide with the wall, it will fall down, or knock off, or jitter.
How can I solve these problems ?
Problem 1 can be solved by adding a entity as the camera’s parent, and add the rigidbody and collision component to it, remove the camera’s rigidbody and collision component.
When rotating the camera, just set the camera’s local eulerangles, when moving, just apply force to the parent entity or set the parent entity’s linear velocity.
I found a solution for problem 2 at http://answers.playcanvas.com/questions/3080/engine-only-best-way-to-attach-camera-to-a-collision-component, which setting
pc.Vec3.ZERO.clone() to prevent rigidbody rotating/rolling.
Cool. Glad you found solutions to your problems! Let us know if there’s anything more your are having trouble with.
But I am not sure whether this is a right solution, or maybe this is a trick way (especially the problem 2)?