Jump to content

registerOnPhysicsCollide With Any


Pryme8
 Share

Recommended Posts

Is there a way to fire a function anytime a specific body touches any other physicsImposter?

I got it for the imposters that are in the scene when the event is bound, but there will be situations where I need it to be more dynamic.

mesh.body.registerOnPhysicsCollide(scene.getPhysicsEngine()._impostors, hit)
 

Link to comment
Share on other sites

  • 2 weeks later...

So how do I make the 'mesh.body.registerOnPhysicsCollide()' function work without providing an array or body for the function to fire in response to.

Basically just like a global every time a physics body touches any other physics body do this method, there has to be one I just cant find it.

 

like a
physicsEngine.registerOnAnyCollide()

 

Link to comment
Share on other sites

54 minutes ago, Pryme8 said:

So how do I make the 'mesh.body.registerOnPhysicsCollide()' function work without providing an array or body for the function to fire in response to.

Basically just like a global every time a physics body touches any other physics body do this method, there has to be one I just cant find it.

 

like a
physicsEngine.registerOnAnyCollide()

 

couldnt you just provide an array of all the meshes in the scene then.  Use scene.meshes??

to make it would for each one just

scene.meshes.foreach(mesh)=>{

if(mesh.body.registerOnPhysicsCollide(scene.meshes)){

console.log(mesh.name);

}

 

}

 

 

sorry this was kind of rush but why not that, seems general enough, right?

edit: i know you didnt want to put an array in but this is the next best thing right? gotta reference them somehow

edit2: there is probably a better way i just dont know of

Link to comment
Share on other sites

I already do that, basically with the mesh.body.registerOnPhysicsCollide(scene.getPhysicsEngine()._impostors, hit)
but I have times where the imposters change quite often so the array from scene.getPhysicsEngine()._impostors is only be correct for a short period of time.

I found a work around but figured it the collisions are firing through the engine when ever a any imposter touches that there should be a way to tie into that event.

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...