Sign in to follow this  
Kilombo

intersectMesh playgroung example ? my mistake or bug?

Recommended Posts

Good afternoon everyone,

 

I've beeing insisting in the past few days in this intersectMesh stuff. Nothing is working to me, so, I took one example from the tutorial, parcialy adapted it (badly by the way, eheheh) and there it goes.

 

In my example, the color of the sphere indeed doesn't change, because there's no intersection, although... he goes in the if clause, i know that because the var called targetz had a value of zero, and only changes to 50 if there's a intersection..... but there's no intersection! So? Why does it enter in the if clause and actually do some stuff, and other don't.

The ball should be red on there's one intersection, and yellow, if it doesn't.

 

Maybe i'm doing something really wrong, really not sure.

 

Please check my examples in the playgroung and check the console: http://www.babylonjs-playground.com/#KI6GH#1

 

I'm insisting on this, because i'm trying to implement one NPC (non player character) and the intersections are the key part for this.

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Line 46 is the magic ! http://www.babylonjs-playground.com/#KI6GH#2

 

When you create your elements, their position is all (0,0,0) until their world matrix is computed, which happens during the render loop.

As its name suggests, 'renderBeforeRender' happens before the render loop.

Share this post


Link to post
Share on other sites

Hi K!  Hi T!  Ahh yes, the very useful renderBeforeRender().  I use that puppy all the time.  :D

 

I'm pretty much confused, but here's #3.

 

I'm not sure what you are trying to do with this PG, Kilombo, but we got red balls, and that's something.  :) In order for an intersection to happen, the yellow ball needed to actually hit something, so I changed its animation path.  You also had paste mistakes in lines 29-31... but that didn't affect your intersections.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.