New version of Character Controller (0.4.1)

For now, while the character is in air you can use mouse to rotate the character( of course that won’t change the movement trajectory of the character). Make sense to rotate using the turn keys too. Will look into doing that.

Yeah, but I do want to change the character’s movement trajectory while mid-jump, can I allow that?

Run, jump and see if you can change the direction in which you are moving while in mid air.

Hi Satguru,

Thanks for sharing this. I’ve been playing around bringing this character into my city model and I’ve been stuck with one issue for days. In my city when I double click using the double click on pointer down a popup box appears. The issue I’m having is when I use this character, double clicking doesn’t seem to work and nothing appears in the console. There might be some kind of blocker somewhere but I’ve been stuck for days trying to find it. For ref my main model is The Block City where you can see the popups when double clicking.

Hi @James1
Nothing happens when I click “The Block City” link you provided. I just get a blank sceen.

Ah, I’m having problems with this page. I think because my HTML file is 40mb so there must be some kind of hosting issue. I need to find another way to serve the model which is currently in base64.

This is the code I’m using :slight_smile:
scene.onPointerObservable.add((pointerInfo) => {
switch (pointerInfo.type) {
case BABYLON.PointerEventTypes.POINTERDOUBLETAP:
if (pointerInfo.pickInfo.hit) {
if (pointerInfo.event.button === 0) {
if (pointerInfo.pickInfo.hit) {
console.log("pointerInfo.pickInfo.hit: " + pointerInfo.pickInfo.pickedMesh.name);
if (meshContent[pointerInfo.pickInfo.pickedMesh.name]) {
console.log(“In the list”); // YES! Our mesh is in the list (ground is not there)

                    toggleModal(); // If there was no modal before, it will be shown; it there was modal already, it will be invisible

							  
                    console.log("Mesh: " + pointerInfo.pickInfo.pickedMesh.name + "; Content: " + meshContent[pointerInfo.pickInfo.pickedMesh.name]);

                       document.getElementById("modal-iframe").innerHTML = "<iframe src=\"https://"+meshContent[pointerInfo.pickInfo.pickedMesh.name] + "\" title=\"Modal\"frameborder=\"0\" style=\"overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:40px;left:0px;right:0px;bottom:0px\" height=\"100%\" width=\"100%\"></iframe>"

                    // You can also use iframe here to display any content. All you need is to bind iframe src value with mesh in our meshContent list
                    // and then change the code above to load the iframe src into the modal
                              
                            }
                            // Later it is possible to simplify this portion with some custom function
                        }
                    }
            }
        }});

The link should work now… I changed the HTML to fetch an external model rather than integrating it into the HTML page.

The double click seems to be a hit or miss.
Works sometime.
You have to double click couple of time and fast for the dialog box to appear.

Not sure why the character controller would interfere with that.
It doesnot capture any pointer events , just keyboard events and you can disable that too by setting

cc.enableKeyBoard(false);

The charcater controller does do ray casting from character to camera, to detect if anything is between them and thus obstructing the camera from viewing the character
You can turn that off with

setCameraElasticity(false);

and if using 0.4.4-alpha.2, then also do

makeObstructionInvisible(false) ;

I’ve tried to add them values in but it doesn’t seem to like it. Where would you include these settings?

I’m not sure why there is a contention either.

see

2 Likes

I think I have it working now thank you. The contention was actually somewhere in my code where I was adding items like: const tn115 = scene.getTransformNodeByName(‘Circle.004’);
tn115.getChildMeshes().forEach((mesh) => {
mesh.isPickable = false;
mesh.checkCollisions = true;
});

for some reason it seems to work after I played around with that. It’s only taken me around a week to figure it out :stuck_out_tongue:

1 Like