- Home /
Caterpillar mechanics in unity.. 'make spheres follow'
Hey all.
Im making a game for class. Its essentially a caterpillar clone from the days of old.
so far i have a script that when applied to a model, it will lead that model forward at a consistent rate. When a collider attached to this object collides with another collider tagged 'left' or 'right' the script will make the model rotate +/- 90 degrees. That part is working fine, whats not working is attaching that same script to multiple objects.
In this case ive used a sphere. The first sphere in the array works fine, butt it doesn't take long for all other spheres to group up and split apart in a way that is not aesthetically pleasing. Ideally, i would like the first sphere to 'pull' the other spheres without causing them to clip through the other assets in the level space. Ive tried using a spring and a joint constraint, but these ideas didnt pan out.
I'm hoping someone here can give me some tips or talk me through the logic to make this happen. I can post snippits of the code or even make a youtube video of the game in progress to help get some feedback. Any ideas?? Thanks!!
$$anonymous$$ake all spheres which are the behind the first sphere follow and lookAt the sphere before them. In that way there will be a smooth snake or caterpillar like movement. Ofcourse you will have to tweak the speed but by far its the best thing you can do
Thanks ill try now. i was just writing a very complicated script that probably wouldn't have worked anyway. lol.
it works essentially the same way as putting the individual scripts on each sphere, they work well for a moment, then they mess themselves up lol.
Your answer
Follow this Question
Related Questions
How to trigger udpate in editor mode only when I modify component parameters 1 Answer
pubblic variable don't get change from script with OnTriggerStay 1 Answer
does not want to work MoveTowards 1 Answer
Game over funcition isn't being called accurately? 2 Answers
Stick rigidbody to surface 3 Answers