How to make curved (smooth) turn for my entities?

So currently i’m trying to optomize my tower defense game, i found a way - i need to delete humanoids in my entities and render them on client side, i’m not sure i’m doing everything right but i’m trying to do what people said to me, but lets skip that part, it’s for my other post.

So, i’m tring to do smooth turn when entities are changing walk direction. I want to achieve turns like on this image
image

Not this
image

What can i use to do that accurate and while using entity’s walk speed?

5 Likes

Soo i have tips for your optimization and with this i can tell you: make more waypoints, you see enemy goes to a waypoint and looks at it, soo if you would make 5 waypoints per turning point, it will don’t lag because it’s only 5 parts or positions idk how you’ve made it. For optimization i’m heavily advice to use linear interpolation for moving entities on server and then animate them on client with animator editor, humanoids can be laggy because they have a lot of propertiess

I already know this tip, i’m trying to do the same, but i still have problem with turns beacuse i don’t want to spawn so much waypoints on 1 turn, and it will be looking a little bit weird.

Thanks for replying! =)

3 Likes

waypoints are not bad, if you’ll position them, you can achieve this

But still i don’t want to spawn so much waypoints just for 1 turn, i don’t like the idea beacuse i have map with so much turns. It will take so much time

1 Like

you don’t need a lot of them, like 2 per turn, it’s enough, there is no other way to do this, + waypoints don’t lag

1 Like

It will look like this with 2 waypoints (not still smooth enough)
image

2 Likes

Also i know there’s should be way, beacuse people somehow doing curve things

1 Like

soo use more, you can that waypoints aren’t parts but table of positions, it would be a lot better, maybe use bezier curves to do this, it needs 3 points

1 Like

You basically want to use Bezier Curves. Look it up for more information.
BezierCurve.lua (616 Bytes)

2 Likes

I don’t like the idea to use more then 4 waypoints (but if i will use less than 4 it still won’t look smooth enough like in other tower defense games), thanks for telling about bezier curves, i’ll try.

2 Likes

Thanks.

There’s minimum characters limit, so i wrote this

4 Likes

How can i use this module script?

1 Like

It’s a module I saved a long time ago. I didn’t make it. I think the way it works is you put 4 parameters into the Calculate function.

  • StartPoint – Vector3 starting point
  • EndPoint, – Vector3 end point
  • Steps, – number of interpolations (higher = smoother)
  • Positions – Array of additional points.

It then returns a new array with the modified poses.
imageimage

As You can see from my terrible diagrams.

The first image is your points without the curve.
The second image shows the curve that gets created from the red dots.

The blue dots are what get returned (equal to the number of steps you provided to the function).

I think that’s how it works.

1 Like

I would try using Bezier curves, by placing two waypoints at the corners and using Bezier curve math you could achieve this effect!

1 Like

So how can i use them after that? It returns in table format and i just need to use for i, variable in ipairs(table) do?

You would use the points it returns as waypoints for your NPC’s.

1 Like

Here I found something that may be better

2 Likes

Ok, i’ll try, thanks! Also i hope with this i will be able to use bezier curve with static speed of zombie walk speed (so zombie won’t speed up or slow down)

3 Likes

It looked more simple, so i used it. It works! Thanks for helping! =)

From problems i can say only that at first waypoint my zombie freezes for like 0.15 second (+ -)
But for now i just put the second waypoint at first to make players don’t see this freeze bug, but i hope i will find way to fix that.

2 Likes