Jump to content

[SOLVED] How to set a mesh position before render?


brucewong21
 Share

Recommended Posts

https://www.babylonjs-playground.com/#4HUQQ#207

Hello again,
I'm trying to figure out how to check for collisions using intersectsMesh method.
The problem is that when I start my scene, the intersectsMesh callback is called since I believe the meshes start at the origin point of the world on the first render before they are moved.

The PG above demonstrates the problem. If you open up the browser's developer console, you would see "SHOULDNT HAPPEN" when the mesh intersections occurred. Any tips on how to prevent this problem? Thank you!

Screen Shot 2017-11-07 at 3.38.48 PM.png

Link to comment
Share on other sites

Thanks for your suggestions guys. I like the computeWorldMatrix idea since it works more along my game flow. I ended up computing the world matrix for my ground object so that it is lower than the world origin so that nothing will intersect it. If I wanted to add walls and such however, those will still intersect my enemies before they're rendered into the world. Is there a solution to this problem that I'm not aware of or how can I use the camera method with my game render loop logic? Thank you everyone.

    engine.runRenderLoop(function(){
      MapManager.update();
      MonsterManager.update();
      WeaponsManager.update();
      ProjectileManager.update();
      cambox.position = camera.position;
      cambox.rotation = camera.rotation;
      scene.render();
    });

 

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