Info popup in json

how to add a ''info" when character reached or passes from that “info popoup”
when we click that info. how we add information in babylon.js
3808_bog'

info.actionManager = new BABYLON.ActionManager(scene);
info.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager[‘OnPickTrigger’], (evt) => {
//click Event
}));
info.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, () => {
//mouse over event
}));
info.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger, () => {
//mouse outevent
}));

info must be mesh

Popover the info name on object once the character reaches to object …?

Good question. I’m about to have the same. I can only assume either by creating a trigger area or by casting a ray from the camera and if the object is ‘in range’ execute the action.
May be @PolygonalSun or @sebavan will be able to help here?

Edit: Or may be a collider with an offset and using onCollide, would probably also work. Providing the offset from the collision does not have an incidence on moving the character or the colliding object.

Tou can use a wide variety of techniques here depending on the area precision. You could manually check if your position is in a box / sphere, use action manager, use collision, use physix collision…

2 Likes

can please given me example…

I guess we could but first you would need to choose from one of the exposed above strategy.

See we cannot build an example for all. Although, parts of the solution for each can also be found in the doc and featured PG. For example, if you want to use a trigger area and the action manager, there’s this part of explanation here.

If you want to use simple collisions, the onCollide runtime (and moveWithCollision in case of a character) will be the way to go.

Still with a runtime animation, checking the position of the character or camera simply relies on capturing the position on each frame and setting a condition that executes the action if the position is in the desired range. Using physics collision is similar to the simple onCollide but needs to be done through the physics engine. Here again there are some hints in the doc. Check within each physic’s engine.

So, what is your say? How do you want to handle collisions in your scene. Do you have a character or just a camera? Is your scene otherwise using a physics engine? Is your scene heavy and requires minimal load to check these collisions?

Edit: OK, Here’s an example I quickly made from a recent PG which uses the ‘onCollide’ method.
I added a plane that acts as a trigger area (also necessary if you want to do it with an actionManager). When entering the plane, the collision is detected and makes the info (in this case a gui button) visible. When leaving the area the button !isVisible.
Press kb ‘2’ to switch to the first person camera, then move on (and out) of the green plane.

2 Likes