0
\$\begingroup\$

I want bunch of circles to follow the player while keeping a distance apart. So far I have this:

local p = {
  x=0,
  y=0,
  life={
    {x=0,y=0},
    {x=0,y=0},
    {x=0,y=0},
    {x=0,y=0}
  }
}


local last={x=p.x,y=p.y}
for l in all(p.life) do
  l.x = lerp(last.x,l.x,0.5)
  l.y = lerp(last.y,l.y,0.5)
  circfill(l.x,l.y,2,7)
  last={x=l.x,y=l.y}
end

But this makes it so the circles collapse into each other and the player. I want the circles to have a distance between themselves and the player.

arythmia follow life

I've also tried this:

  l.x = lerp(last.x*0.8,l.x,0.5)

This leaves a distance as I want but the trail is always on the upper left, barely following player.

I want the trail to stay always behind the player.

Probably I can achieve this by stop following if the distance is less than threshold.

\$\endgroup\$
1
\$\begingroup\$

I did it by adding a condition before modifying the position of the trail:

if vdist(last,l) < 10 then
  // adjust position
end

it works now.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.