Jump to content

Repeat different times the applyImpulse on different meshes


DellaFree
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Well, this way the shoot frequency depends on the range to the target. I guess that's not "realistic" :P 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 :-/

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