HI!
I am making my first game with babylon and visual studio code. I am using mutiple scripts (they are commented on the playground).
on the initializing of the game you see 4 “hole” objects (initHoles(player, scene). You move the player clicking on the ground. if the player collides with a hole you get a console.log DEAD. It is working!
the problem starts here: After one second each hole gets replaced with a new one (setTimeout(holesTimer(player, scene), 1000) I register the collisions for those new ones with the same function .The replacement of the meshes works but the player is not colliding with the new holes. any idea why?
every thing relevant should be on the “HOLE CLASS” (the pg is big):
https://playground.babylonjs.com/#G3QD3H#2
Thank you very much!
Hiya M! I’ve just started looking-around in your playground. You’ve been busy in here. Nice work.
Um… when I change holesNumber = 3 (line 32)… stuff falls apart and I get a bunch of console vomit. Why do you think that happens? Is it possible that you are somehow “mis-managing” your holesArray?
Perhaps you are accidentally registering intersect actions… on the wrong hole.mesh.actionManager? Maybe you are missing the newly-created holes, by targeting the wrong holesArray elements (when registering actions on the new holes)?
Got your shifts, unshifts, pushes, and pops… properly applied? That holesNumber should be able to be adjusted… without errors, one would suspect. Just some thoughts… and I’ll keep thinking, too.
1 Like
Well,
Okay, I tested the code, I think the problem is in the create new hole function.
if lastelem==3 nothing console.log on collision.
if set to 2 a fixed hole appears that register collision…
Anyway, I don’t have time to test more…
and it complains the main camera is not set
1 Like
thanks for the hints!
this one should fix the bug with the holes number = 3
https://playground.babylonjs.com/#G3QD3H#4
(any too big number would crash the scene, because the while loop tries to position the hole without intersecting another one. on the singleNewHole function this doesnt happen, it positions the hole anywhere)
About the “missing active camera”, I just noticed this. In my local project this isnt happening mmm.
i am going to keep looking!
Got It! As i tought it was something stupid…
the newly created objects had a height of 0.1 (the init objects had 0.5). So the player was never colliding with the new holes. now they do! thank you anyway!
1 Like