Generation

generate functionThu, 23 Feb 2023

unity 2d object movement in spiral pattern towards the centre of circle

Vector2 movingInSpiral(Vector2 start, float time, float distance) { Vector2 direction = Vector2.zero; if (time > Mathf.PI) { direction.x = Math.Sin(time) * distance; } else { direction.x = Math.Cos(time) * distance; } direction.y = Math.Sin(3 * time) * -distance; return direction; }

Questions about programming?Chat with your personal AI assistant