Could someone please assist me with this situation?
How can we manage this issue and change the camera radius dynamically based on the collision event? (without use the checkCollisions method)?
Thatās a very interesting question. Iām eager to read the answer.
Conceptually, there needs to be a way to determine when the player is obstructed. The first thought that comes to my mind is to try using ray picking. The working assumption here is that if there are one or more meshes in between the camera and the player, we want the camera to then be in front of all of those meshes.
What you could try is to fire a ray from the player or camera target (origin) to the camera (target) and check what the first mesh is that gets hit. The picking info provided by that pick should then give you a point where the ray actually hit. You could then use that point, with playerās position (or the cameraās target), to determine what the new radius should be.
Yes, my concept was to create a ray between the player and the camera, like you mentioned. But, could you kindly explain to me how we may compute a new radius based on the new obstrat position?
And again reset it?
Actually, it is already implemented here in a simple way - GitHub - ssatguru/BabylonJS-CharacterController: A CharacterController for BabylonJS
I would recommend a very cheap way.
- create cameraHitBox(mesh.createBox)
- and set cameraHitBox camera under (CameraHitBox.parent = camera)
- and try to any some this
CameraHitBox.isVisible = false;
CameraHitBox.isPickable = false;
let tempIsHi = false;
scene.onAfterRenderObservable.add(() => {
if (CameraHitBox.intersectsMesh(hitObject : tree in video)) {
if (!tempIsHi) {
tempIsHi = true;
//start event. example : camera.radius = 3;
} else {
tempIsHi = false;
}
};
});
Oh, Thatās nice but does it handle the camera with collisions only from this āelasticityā (bolean)? Or are there any options to further tweek the camera behavior/transition on collision?
And then, sadly I should say, the demo doesnāt show this.
I only found this short part in the description
āBy default the camera behaves āelasticallyā. In other words if something comes between the camera and avatar the camera snaps to a position in front of that something. This way the avatar/player is always in view. To turn this off useā¦ā
Well, worth trying it out anyways.
Yet I believe the idea of eventually having this behavior (with options) as an integrated part of the camera behavior for 3rd person cam in BJS would probably be an awesome piece to have, wouldnāt it? @PolygonalSun
@11128 Thank you for your assistance. The experience is not smooth since the screen flashes when adjusting the radius, and the radius is static, which will not function in a dynamic collision situation.
You may try it here - https://portal.metadojo.io/
(It uses CharacterController with some modifications for better elasticity).
Nice, thanks. Didnāt realize you implemented this in your project. Thanks for the tip and have a great day
@labris Itās fantastic, however weāre not utilising the navigation plugin. Would anyone be willing to offer their playground as a demonstration?
@Nilesh_Ghanchi We also donāt use navigation plugin, just this CC - GitHub - ssatguru/BabylonJS-CharacterController: A CharacterController for BabylonJS
Thanks @labris. It works for me thank you so much
I want to thank all of you for a great support.
@labris It would be great if you could help me with a little issue with how you handled the cameraās reset radius once it was free of collisions in your project.
Hi Labris, I have my babylonjs set-up as one html file. How do I integrate this controller into my html file? Do I need to change the set-up of the file into multiple files? - https://theblockcity.com/metaverse.html
Iām just creating a third person view so I can walk around the city in third person.
Hi James,
Hope you are well. Donāt know the answer and hopefully @labris will answer soon.
Just wanted to ask āPlease let me know when itās readyā. Iād love to have a look at how your scene looks from a street view. Meanwhile, have a great Xmas
Hi Mawa, Iām good thank you. Hope you are too and hope you are having a great xmas holiday.
Thanks, Itās still a bit buggy and slow but hopefully it will be good enough when itās all set to walk around and probably optimized a bit more.