Spawn an object behind player

Top down controls. I’m making what is essentially a snake-game: eat apples, add 1 unit to the length of the snake.

I’ve figured out a workaround, something like,

When head collides with apple:

  • destroy apple,
  • add +1 to Variable.Length
  • spawn body (behind head, using Var.Length * 32 [pixels] as distance)
  • spawn directional arrow.
  • Apply force to body = to angle of head

When body is in collision with direction arrow:

  • apply a force (appropriate direction and speed) to body

when no body is in collision with directional arrow:

  • destroy directional arrow.

My issue is I’m unable to spawn the body portion behind the head relative to the head’s current position and angle. I can “move object around another” (head.Angle() + 180 at 32 pixels distance) or “create object” at an x and y position (x = head’s X -32, or some such), but how do I create an object around another, so to speak?

Is there an easy way to do this?

1 Like

Use a ghost spawner object that follows the head and spawn the body on its position?
Or add a custom spawn point on the head object?

Make every body part to have it own spawn point for the next one. The new body part just spawns at the spawn point of the previous one.