Yo,
I’m trying to make Enemy Movement in my Tower Defense game more similar to the one from TDS. Right now the Enemies are moving in a straight line and one behind each other. I want them to be placed more random and not really on the same X-Z Axis (Depends on the Rotation of them). How can I even achieve that?
Screenshot from TDS:
As you can see on this ss the zombies aren’t walking in the same X-Z Axis they are more to the left or to the right.
Screenshot from My Game: As you can see here. The Enemies are walking in a straight line in the middle of the path. Not being more to the left nor right
So how can I achieve making smth like this? btw i’m using Client-Side rendering to make it more optimized
Why don’t you give them a random offset when the spawn and the same offset to the goal. Just make sure the offset isn’t too much or the NPC will go off the track.
Use CFrames to offset the entity’s position. What you are doing right now is just incrementing/decrementing the Vector3 of the entities, which will lead to desynchronization by a few studs.
I presume you are sending the CFrame of the entity to move them in the client (and I highly recommend to offset on the client), so you could multiply the CFrame by the randomized offset, sorta like this:
local offset = CFrame.new(randomizednumber, 0, 0) -- offset the CFrame on the X axis.
FinalCFrame = SentCFrame * offset