Slastraf Posted November 30, 2015 Share Posted November 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
Rick Posted November 30, 2015 Share Posted November 30, 2015 Step 1, have you tried just adding 30+ turret models without scripts attached to see what kind of FPS you get? Try that first. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted November 30, 2015 Author Share Posted November 30, 2015 Step 1, have you tried just adding 30+ turret models without scripts attached to see what kind of FPS you get? Try that first. yes , i even uploaded some screenshots some days ago : http://www.leadwerks.com/werkspace/page/viewitem?fileid=562789317 Quote Link to comment Share on other sites More sharing options...
Rick Posted November 30, 2015 Share Posted November 30, 2015 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. 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.