How to make working snake movement?

Hello, Currently I am attempting to create a slithering snake. One like slither.io. The problem is, I can’t seem to get the body connected to the head smoothly, and tweening seems really laggy. I have tried moving all the body parts forward to the next spot every few seconds, align position, and tweening. I would like to have a functioning snake like Slither-Simulator. Could someone give some assistance, of point me in the right direction?

2 Likes

so the head should be the character and then each client should move the tail in a localscript based on the snake length

its also a lot more optimal to not move all the parts of the tail and to only move the last part of the tail to the front

1 Like

Why would each client move the tail, why not the server? If I only move the back and front, the pieces in-between don’t move at all, which doesn’t look right.

1 Like

you move the back to the front like this
image
1 part at a time

if the server sends 100 parts positions every heartbeat it will send around 271KB/s per player
if you have 10 players in your game that means the server will have to send around 2710KB/s

if you position the parts with physics it will use less data but still wont be smooth

if you don’t want there to be lag and you want it to move smoothly you need to position the tails in localscripts that will use 0KB/s and all the server has to do is tell the players how long each players tail is you can do this using attributes or intvalue

1 Like

So, to clear everything up, I should move the all snakes on the client? Also, will that have any negative affect on snakes colliding with other snakes?

1 Like

all clients tails should be around 99% identical as other clients tails if you do it locally

you could make it the job of the player who got touched or the player who touched to report the touch to the server

Ok, thanks for clearing that up! 1 more question, currently for all the snake tails I am using :MoveTo(). Is there a better way? I have tried tweens, alignposition, and ropeconstraints. Currently MoveTo() works, but is there a way for better performance?

image

setting the CFrame/Position like this image would have the best performance

I would want to move the WHOLE snake slowly, so the middle looks like it is moving. If I just teleport the end to the front, The middle is not moving at all.

if you want to move lots of parts

then using physics or using BulkMoveTo WorldRoot | Roblox Creator Documentation are the fastest options

this video might help you decide