Jump to content

Physics doesn't work with local coordinates (on a child element)


SebRomeo
 Share

Recommended Posts

Hi guys :)

I've tried a lot but can't find any solution. Also I try to find in documentation which is not very detailled for the moment about physics behavior but doesn't find an answer...

I use oimo.js and when I try to enable physics on a child element it bring me the error : "TypeError: e.physicsBody is undefined"...

I may use onCollide but I can't find any ressource on it's behaviour and intersectMesh....but as I have to do it with hundred of object I wonder if there is a different approch than a "brute force" testing of all intersect mesh with all others ( approx. 10 000 test each frame )

 

Thanks a lot :)
 

Link to comment
Share on other sites

Hiya SR! 

First, that error has been seen in CannonJS, too.  Even though it is annoying, I think it can be ignored, for now.  No impact to physics operations have been seen so far, caused by that error report.  BUT... it could be related to the ORDER that the physics impostors are added to parent/children.

You should probably read this thread.  It does some talking about the ORDER of impostor-adding.... when dealing-with parent/child compounding.

This badly built Oimo document might be of some help, too.... for advanced OIMO learning/hacking.  (I don't wish that on anyone)  ("native" calls are scary!) :)

And... lastly, we have seen SOME indications that... it is un-wise to scale a mesh that will be used as a physics parent.  By using the meshBuilder system of creating basic mesh, you can set some mesh size/scale dimensions... without needing to use .scaling.  Scaling, rotation, and position are handed-down from parent to children, and this is how it could be related to the "order of adding impostors". 

I'm no expert, and docs are introductory level, so far (but thank goodness and Raanan for those, too). 

Perhaps you can help us with advanced physics docs, in the future?  :)  Don't forget playground searching, too.  Hope this helps.

Link to comment
Share on other sites

Man !! A big thank you for answer !

The thread seems to point this exact problem ;)
I tried everything, and you are true, that in cannon it doesn't work too..

Also, I'll be glad to help for all that when I know more about it, I very find that framework revolutionnary and a very good in the concept, tools and community :) but as it is fresh new, there is still work to achieve.

Thanks for all your contribution :)

Link to comment
Share on other sites

Just to give the solution that worked for me :

Creating Childs before Parents as solved the issue for me !

 

/* Create child sphere */

var sphereChild = BABYLON.Mesh.CreateSphere("spherechild", 16, 1, scene);
    sphereChild.position.y = 1;
    sphereChild.position.x += .1;
    sphereChild.physicsImpostor = new BABYLON.PhysicsImpostor(sphereChild, BABYLON.PhysicsImpostor.SphereImpostor, {mass: 2}, scene);

/* then create the parent sphere */

    sphere.physicsImpostor = new BABYLON.PhysicsImpostor(sphere, BABYLON.PhysicsImpostor.SphereImpostor, {mass: 2}, scene);

/* then add relationship */

    sphereChild.parent = sphere;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...