Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello ! I have a problem with the collision detection between two nodes, when I display the results of the collision detection method ccbGetCollisionPointOfWorldWithLine (startX, startY, startZ, endX, endY, endZ) I see that it returns me a collision point when the node does not collide with other nodes but when it collides it displays 0 -> null. So what I'm asking you is to tell me does the method work like that or is it a bug or I am not very well understanding how to use the method, this is how I did the code : var coll = ccbGetCollisionPointOfWorldWithLine(ball.x, ball.y, ball.z, wall.x, wall.y, wall.z) if (coll != null){ ......... } print(coll) print result : --------------------------------- - pas de collision: (2123.45,1321.54,5688.45) - il y a de collision : 0 |
||||
|
If something between of two points you selected WALL and BALL then it returns point.xyz If there is nothing between BALL and WALL then it returns null. |
||||
|
Collision detection works with the line, not with yhe object if the line between 2 points gets collided with any collidable object (mesh) then it will give the position of collision. Otherwise it will remains (0,0,0). When the node is overlapping the other node there might be less chances that it will give you the accurate value because the line drawn from the object might not be colliding with the overlapping object either because of the size of the object or due to culling. Or maybe the position from where the line is drawn is not from the object to another point, it might be from the camera to the object so there might be chances that another node which you wants to check collision with is not actually intescting between the line drawn hence giving the (0,0,0) result. Try checking the position of the line from where it is drawn. Or make sure it is starting from the main object and then the ray goes into the world. And also make sure that the object of which you want to check the collision lies between the line and the main object. Means intersecting the line coming through the main object. Then only it will give you the correct collision point. Hope that helps😇 |
|