Tower Defense: Enemy System

I presume the reason why it’s taking up so much is actually rendering the entities; especially since you are still using humanoids. (forgive my ignorance, I haven’t really read through all of this, especially the code.)

For the entity movement, I’d suggest using bones instead. Transforming bones are very free to render, saving up resources. For the entity offset, you can multiply the CFrame (Bone Transform is a CFrame) by the offset on the X axis.

However, since you are using :MoveTo, you’re gonna have to rewrite the entity movment.

You can read this devforum post for more details regarding bones, and other optimization tactics you can use: here

However (thank you so much for that, I will definetly look into it and optimizing the game hardcore)

But my main question is, how can I fix it from all going into one linear line, when i want them to all be like how tower defense simulator has their systems: (Image Below)

Everything works decent, but I need to figure out a way to add space between the enemies so they are not all hogging each other’s spot as-well making it so they all follow the TDS movement system, rather then staying linear (I don’t understand the correct terms for it rn, its late and i’m tired lol…)

You can use CFrames to offset your entity’s position.

However, you’ll need to rewrite how your entities move :frowning: Good thing is, I’ve already incorporated this style of movement into my own TD game.

I’ll be giving you a place file of a snippet of my code; this includes the movement and the offsetting. Comments are already provided for your own benefit.

For smooth cornering, you can use beziers or do some math to calculate the turning angle.
entityoffset.rbxl (82.4 KB)
this is a way for me to not overexplain things lol

I’d also suggest starting to move to client-sided rendering and making the entities non-humanoid. Since you’re basically rewriting the code for your entities, now should be a good time to move to client-sided rendering.

1 Like

My bad, I missed your reply. If you click on the “mode” tab you should be able to switch to detailed view which will give you a full breakdown of everything happening under the hood each frame. The yellow bars represent how long it takes for a frame to process, the taller the bar the worse.
If you click on a bar it’ll scrub the timeline to when that frame was processed. You can then drag the view around, scroll up/down to zoom in/out, etc.

If you need more info, take a look at microprofiler documentation. You’ll be able to figure out exactly what’s pushing those yellow bars all the way to the top lagging your game.