Jump to content

How to go about making a multipart snake?


Eternaldoom

Recommended Posts

Hi,

 

I've wanted to create a multipart snake mob for a while now. The idea is a long chain of entities that follow each other in a smooth looking animation. Here's an example of what I mean: https://www.youtube.com/watch?v=9UxAZouGJfU.

 

So far I've tried making the parts simply follow each other, but that just looks like mobs following each other, the rotation of each piece is very wobbly. Any idea how to go about this?

 

Thanks!

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

I would move the head entity using regular navigation and if the head moves, then move all the pieces to the position that the preceding part just had. Note that you only want to update the positions if the head moves otherwise the whole thing will compress -- the head will stop then all the other parts will keep moving until they're in same position. And then just rotate each part to line up between the part in front and the part behind. I think that should be all that is needed.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Thanks Jabelar. Wouldn't it have to go very fast or be very small for that to look good though? I assume you just mean move each piece to the last tick position of the piece in front of it?

 

Yes, it'll be a bit like Naga.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Link to comment
Share on other sites

Thanks Jabelar. Wouldn't it have to go very fast or be very small for that to look good though? I assume you just mean move each piece to the last tick position of the piece in front of it?

 

Yes, that's what I mean. Yes to keep it connected you would need to ensure that the head can't move more in a tick than half the length of a segment.

 

The problem with the alternative is the issue of colliding with blocks. The head will do actual pathfinding, but you don't want the next segment to move straight to the head position because that might go through a block. The nice thing about the head's previous position is you know it is the actual path the head took.

 

The video link you shared didn't have the same problem because the parts were just arcing in the air. But imagine a snake slithering through some bumpy terrain.

 

I suppose another way would be to have each part do some path finding. So the first part does its own thing, then next part finds a path to the head, etc. However, I think that the pathfinding may be difficult if it thinks the parts are going to collide and it is not clear to me that you could really do it properly. For example, you don't want the next segment to go to the middle of the head, but rather connect to the base of the head. Also, it would be difficult to know the rotation angles.

 

I guess the ultimate is to make your own pathfinding algorithm for the head that saves the path (not necessarily the last tick position, but also all the points in between) and then places the body segments along that path.

 

It is actually a pretty tricky problem. That is why the multi-part vanilla dragon is flying and goes through blocks -- then it doesn't have to worry about parts navigating a complicated path.

 

Ultimately this is Minecraft though and the imperfection is the charm of the game. So if you have a blocky snake that doesn't perfectly connect most people would still appreciate it.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.