DellaFree Posted August 6, 2015 Share Posted August 6, 2015 Hi guys ! I 've tried to add some features to an old PG (that I have just mada for a previous topic); that one : http://www.babylonjs-playground.com/#1PTVTW#9 I try to apply an impulse to a sphere that "come out" from the ships (when they reach the island) and hit the target (the cylinder in the middle). It works, but just the for time; instead, I would repeat these applyImpulse on every 1sec (or 2sec), after they reach the island. I try to apply the setTimeout() function, but the result does not work well. Here the other PG (it doesn't work): http://www.babylonjs-playground.com/#1PTVTW#10 . So have any idea on how can I do that? Do you think it's the best way?Thank you in advance for your time and patience,cheers Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 7, 2015 Share Posted August 7, 2015 Hey again, something like that might work: http://www.babylonjs-playground.com/#1PTVTW#11 Use the timeout after the shooting for each ship in a separate function. Not sure if it already stops at the right time. Might need some improvement Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 7, 2015 Share Posted August 7, 2015 Why not shoot another bullet after the last bullet hit? this way you avoid using setTimeout and you control your code much better:http://www.babylonjs-playground.com/#1PTVTW#12 (there are some other code changes, but in general it is the same). It of course depends on your game use case. BTW - I love the way you created the ships! this is such a nice way of using the cylinder limitations. Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 7, 2015 Share Posted August 7, 2015 Well, this way the shoot frequency depends on the range to the target. I guess that's not "realistic" What if the the ships want to use some kind of minigun with a high rate of fire? http://www.babylonjs-playground.com/#1PTVTW#13 PS: I guess that shows the problem that I mentioned above. All ships shoot at least once ... guess you just have to check if the cylinder still has life before the first shot. BTW: I always get the console error: "Uncaught TypeError: Cannot read property 'animations' of undefined" but I don't really understand why. It has something to do with the move animation that tries to animate a ship that's not there (the one with index 10 in an array of 0 to 9). Not sure if I am just confused but somehow it doesn't make sense to me since there is a check for k<ships.length :-/ Quote Link to comment Share on other sites More sharing options...
DellaFree Posted August 9, 2015 Author Share Posted August 9, 2015 Hi guys! Sorry for the delay. I love your solutions, both work fine. Really thanks a lot guys 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.