Hi All,
I'm trying to set an offset for a snake or centipede nodes. I don't know the math behind it. The centipede nodes follow the head, hence the position is copied.
I tried the following idea, but it didnt work
for (var i:int = m_nodes.length - 1; i >= 0; --i)
{
if (i != 0)
{
/*
m_nodes[i].x = m_nodes[i - 1].x;
m_nodes[i].y = m_nodes[i - 1].y;*/
var currAngle:int = m_nodes[i].rotation + m_nodes[i-1].rotation;
trace("curr Angle"+currAngle);
m_nodes[i].x = m_nodes[i - 1].x + Math.cos(currAngle);
m_nodes[i].y = m_nodes[i - 1].y + Math.sin(currAngle);
}
else
{
m_nodes[0].x += m_nodes[0].vx * (100) * dt;
m_nodes[0].y += m_nodes[0].vy * (100) * dt;
}