Jump to content

Turret bullet Emitter effect and Leadwerks performance


Slastraf
 Share

Recommended Posts

http://pastebin.com/yQ2jHPii

> I put my script on pastebin for better overview.

This is the script I attached to a turret .

Basic explaination: It ckecks for enemies nearby and alligns itself to them, calls shoot() function once in a while.

The Bullet itself is only for the visual. To hurt the enemy, I will later acces the enemy script trough the turret and call a hurt function.

In the start funcion I set up an emitter which should look like a bullet flying .

I want to know how i properly let the emitter play , and have multiple bullets at one time. ( or just how to play it , i can make the bullet run faster so it would be no problem if it gets resetted).

I made an attempt in the Shoot() function, but i cant see anything inside the game.

 

2

The performance is still a littlebit low, I can spawn ~30 turrets at normal fps and when I spawn more it gets lower (not over time, the more turrets the less fps). I personally think its caused by my computer or lua, but still if you can find anything that could cause less performance please tell.

Link to comment
Share on other sites

OK, so step 2 is to figure out what part is taking the most time in your script, by commenting areas out and see what it is. I often do things inside UpdateWorld() vs UpdatePhysics() and when in UpdateWorld() for AI stuff I often don't do it every frame as it's generally overkill. Generally I make a timer and only do AI type stuff every x ms. Try 50ms and play around with what may work. This can help increase FPS, but first figure out what part of the code is taking time by commenting things out and rerunning. Rinse repeat. That's how I generally do about it anyway.

 

If I had to guess I would maybe think the ForEachEntityInAABBDo() callback, again, doesn't normally need to be called every frame as it generally changes less often as things move slower than each frame is running.

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.

 Share

×
×
  • Create New...