I’ve followed the instructions here trying to get camera collision to work. This process doesn’t work correctly at all. I’ve also tried to implement the desired functionality with a number of different variations of the linked instructions. Some of the issues are as follows:
- Don’t get collisions between the camera and any object with ‘Static Physics’.
- Don’t get collisions between the camera and any object with a ‘Mesh Collider’ if that mesh is a surface (i.e. it isn’t a mesh which encloses a volume, e.g. a plane)
- Using a lower-level functionality, e.g. PhysicsSystemRequestBus.GatherPhysicalEntitiesAroundPoint also has the above issues.
- Setting custom gravity for an object with ‘Character Physics’ only works until you ‘Set’ any of the properties of the object with the PhysicsComponentRequestBus.
- If instead of setting the camera world transform (as is done in all of the scripts in StarterGame) the camera is given an impulse which would take it to the desired location in one tick, the controller breaks entirely - camera only moves up+down while in the air; only when it’s on a surface does the left/right/forward/back impulse work.
- Acceleration according to PhysicsComponentRequestBus is always 0 even when object is under the influence of gravity and is clearly accelerating.
I’ve looked at how this is accomplished in the StarterGame. It seems to use some horrible hack based on raycasting (which doesn’t even work - if you stand beside a wall on the left, the camera is pushed out of the wall; on the right, it is not). Using raycasting to accomplish this is not an unacceptable solution, both performance-wise and in terms of the maintainability of the logic.
The collision system is the preferred way to implement this. To be specific, I would like an entity
- which collides as a ball,
- is not affected by gravity,
- has very high ‘friction’ even when not in contact with anything, and this friction is not affected by the type of surface with which the entity is in contact,
- receives a forward velocity (i.e. is not simply ‘teleported’ to the target location as SetWorldTm does) when pressing a specific key
Each of these requirements is easy to implement separately. However, I haven’t been able to implement them all together due to the issues described above.
To summarize: Is there a complete example anywhere of camera collision without raycasting? Or an example of e.g. a spaceship or some other vehicle whose locomotion is implemented with scripting, which collides with its environment as a rigid body? Did the linked instructions never work or were they broken by some update since their posting? Is it just me or is the physics system generally very broken?