C
C#3mo ago
KleinRiese

✅ Problem with a Recursion Function

I am currently programming a Snake-Clone and want to count the Parts(length of the tail) of the snake. Each part has a reference to the next part, called "next tail part". Is the recursion-function the problem, or something else? I am Printing the Result, by calling the function in the Debug.Log function : Console.WriteLine(DebugSnakeParts()); Function: private int DebugSnakeParts() { if(nextTailPart == null) { return 1; }else { return DebugSnakeParts() + 1; }
1 Reply
KleinRiese
KleinRieseOP3mo ago
Oh and I am getting a stack overflow error I fixed it
Want results from more Discord servers?
Add your server