# How does Spore Spawn's neck work?

In super Metroid there’s a boss named spore spawn who has this neck that’s made of individual sprites that form a line between his head and the base of his neck. (There are other bosses who do this but he’s the one I remember.)He moves his head in a sort of whip-like dangly fashion, and I’m curious, does anyone know how this works, and more importantly how One might implement it into a unity project? I’m trying to figure out ways to make a whip in a 2.5d project, and I think this method could work(I’m sure there’s better ways but this fits the aesthetic pretty well).

Good question!

This is speculation:

I know the effect you are talking about is a very old effect. Gives fluid like movement to points of a line, and positions the sprites at intervals of those points. So you’d probably have a longer point of lines then the number of points you layed sprites over and every so and so points, every third point or so you lay your sprite.
You then modify positions or all sprites using what could be defined as 2D inverse kinematics. That is; I decide the rotation of one base point, and it effects the rotation of other points in kind of delayed lerp. The other points want to pursue a relative position or comfortable distance from their neighbors. So something along these lines I would expect is how it is done.

The last time I played super metroid was 10+ years ago so I had to look up what you’re referring to. I do remember that huge eye which is what you were referring to, right? The enemy itself simply moves in a “circle” by using “cos” and “sin” but have the sine movement (y axis) at double the speed which gives you that Lemniscate / figure 8 movement. The “neck” is just two sprites that are positioned at a percentage along the line that connects the neck with the fix point on the background. That’s all. So there’s no “whipping” going on as the neck is just a simulation anyways

Yeah, what @Bunny83 says… I love coding these things so here we go! Full package attached too.

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// @kurtdekker - Spore Boss; figure 8 plus neck
// put this on the head itself

public class SporeBoss : MonoBehaviour
{
public Transform Anchor;

public GameObject NeckChunk;

public int numNeckChunks = 10;

public Vector2 Size = new Vector2( 4, 2);
public Vector2 Rate = new Vector2( 1, 2);

float t;

List<Transform> Necks;

void Start()
{
Necks = new List<Transform>();

for (int i = 0; i < numNeckChunks; i++)
{
// parent them to our parent
GameObject chunk = Instantiate<GameObject>(NeckChunk, transform.parent);

}
}

void Update ()
{
t += Time.deltaTime;

float angleX = t * Rate.x;
float angleY = t * Rate.y;

Vector2 position = new Vector2(
Mathf.Cos( angleX) * Size.x,
Mathf.Sin( angleY) * Size.y);

transform.localPosition = position;

// update neck chunks
for (int i = 0; i < Necks.Count; i++)
{
float alpha = i;
alpha /= (Necks.Count - 1);

Vector2 pos = Vector2.Lerp( Anchor.position, transform.position, alpha);

Necks[i].position = pos;
}
}
}
``````
1 Like

Kurt, you sir are amazing. A touch of reconfiguring and reskinning and this should work absolutely perfect for what I’m doing. You’ve been immensely helpful for just about everything I’ve needed off this forum. If I ever get around to releasing this project, would you mind if I have you credited for scripting consultation or some such role? You’ve been super helpful and I’d like to give you some kind of thank you like that.

1 Like

I would be honored if you threw in a thanks but it is not necessary or expected!

1 Like

Awesome, I’ll be happy to