ian Posted August 27, 2016 Share Posted August 27, 2016 Hi, I prepare simple playground http://www.babylonjs-playground.com/#21STMC#0 Can anybody show us how to program switchForBall as observer and ball which trigge switchForBall? greetings Quote Link to comment Share on other sites More sharing options...
ian Posted August 27, 2016 Author Share Posted August 27, 2016 Ok I try myself with switchForBall.onCollideObservable.add( function() { console.log("Switch collide happend"); }); But nothing happend, it shoul call console.log, but doesn't. What I'm doing wrong? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 27, 2016 Share Posted August 27, 2016 player_box.body.grounded = false; player_box.body.collisionResponse = 0; player_box.body.addEventListener("collide", function(e){ player_box.body.grounded = true; player_box.body.collisionResponse = 1; }; scene.registerBeforeRender(function(){ if(player_box.body.collisionResponse){ player_box.body.grounded = true; player_box.body.velocity.y = 0; }else{ player_box.body.grounded = false; } ... Just add an event listener to the physics body for a collide. Quote Link to comment Share on other sites More sharing options...
ian Posted August 27, 2016 Author Share Posted August 27, 2016 nice to see this alternative. I'll try it. Can you tell me which API are you using here? Is this cannon's API? I know that that is possible. And I like this alternative scene.registerBeforeRender( function() { if (ball.intersectsMesh(switchForBall, false)) { console("ball mesh intersect switchForBall"); } }); But I really would like to know if onCollideObservable works. Maybe Deltakosh should know. I think he is programirmg babylonjs API. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 27, 2016 Share Posted August 27, 2016 I think thats what the Collide event listener is? That should work for Oimo and Cannon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.