Jump to content

Point() lags when multiple Objects use it


Slastraf
 Share

Recommended Posts

I have a few turrets and some enemies just with health and the walk in a circle.

 

http://pasteboard.co/LnHZqB1OU.gif

 

As one can see from the gif , when one turret is in the scene it is turning smoothly.

But when multiple ones are spawned, they only update once in a while.

 

The line uses Point() and looks like this :

 

if self.target then

self.entity:Point(self.target.entity,2,Time:GetSpeed()*0.1)

end

 

How can i fix / optimize this ?

 

The gif is (only) 6 mb but it takes long to load, sorry for this.

Link to comment
Share on other sites

How is the 'self.target' being set? If by pick, maybe some of the turrets do not have a target or only see a target occasionally if the pick's collisiontype is hitting the turrets? Hard to tell without actual example or code to try.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

How is the 'self.target' being set? If by pick, maybe some of the turrets do not have a target or only see a target occasionally if the pick's collisiontype is hitting the turrets? Hard to tell without actual example or code to try.

Its the same script as here, it performs AABB

http://www.leadwerks.com/werkspace/blog/1/entry-1671-building-the-turret-ai/

but at the first line I added

if extra.script.target == nil then

because the method would be called too often resulting in a crash, if multiple enemies are nearby

Link to comment
Share on other sites

That script posted in that blog is a WIP that is missing alot of features that its supposed to do - no check of team ID, no occlusion check, no rotating the turret... etc... Again, without an actual example or code to try, it makes it hard to troubleshoot.

 

Edit-- I assume you are using the updated code shown here? http://www.leadwerks.com/werkspace/blog/1/entry-1673-building-turret-ai-part-2/

 

And if that is the case, then it performs a pick that may not see an enemy. Your example 'gif' has everything ontop of each other. Try spreading the turrets out and put the targets in the center to see if this helps your situation. Also note what Josh posted at the beginning of the blog:

"To avoid overloading the engine I am only performing the visibility test at most once every 500 milliseconds. This provides near-instantaneous updating while preventing the picking from becoming a bottleneck and slowing down performance."

You may need to increase this time if you are performing so many picks.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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