Hey guys…
I am fairly new to Castle Game Engine and I have been trying to work with 3D object movement using the physics system, but I’m running into some issues. Specifically, I want to create a simple setup where a player-controlled object can move smoothly across a surface and respond to collisions naturally (e.g., bounce off walls or other objects).
I’ve looked through the documentation and some of the example projects, but I’m still not entirely sure how to apply forces correctly for this. Should I be working with rigid bodies and applying forces directly, or is there a better approach for handling basic movement and collision response?
I have not found any solution. Could anyone guide me about this? Also, are there any common pitfalls I should watch out for when dealing with physics in CGE?
Your help will be grateful for me!
Thanks in advance!
Respected community member!
Hello!
To have the player behave as fully realistic physics object (like a ball/box that is being pushed around the level using physical forces) → yes, you should just use CGE rigid bodies and call TCastleRigidBody.AddForce
, TCastleRigidBody.AddTorque
and such methods to move/rotate the player.
We actually have an unfinished implementation of TCastleThirdPersonNavigation
to move the avatar using forces.
Note that we have a plan to implement new navigation components in New physics based first/third person 3d and platformer like modular navigation + input axis and others by and3md · Pull Request #533 · castle-engine/castle-engine · GitHub . This will probably deprecate TCastleThirdPersonNavigation
, leaving the ctForce
never finished. But it will take still some time to finish that PR (but we want to do this in 7.0).
I have possibly overwhelmed you with internal information you don’t need Don’t worry about details. The short version is really that you can implement such navigation on your side, by not using any ready CGE navigation components and just calling RBody.AddForce(...)
with proper vector in response to user pressing keys.
This is all assuming you really need to have player following physics. For many games, it is not necessary or even not desirable – unrealistic physics movement is often fun for players. So if you don’t really need fully physical behavior, consider also just using TCastleThirdPersonNavigation
for 3rd-person navigation of TCastleWalkNavigation
for 1st-person navigation without physics.