Sign in to follow this  
Followers 0
Slastraf

Point() lags when multiple Objects use it

4 posts in this topic

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.

0

Share this post


Link to post

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.

0

Share this post


Link to post

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

0

Share this post


Link to post

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.

1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Create Your Account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0