Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Weird bug in a health script

Discussion in 'Visual Scripting' started by jasonasaad2, Feb 20, 2021.

  1. jasonasaad2

    jasonasaad2

    Joined:
    Nov 30, 2020
    Posts:
    51
    I made a health script for a game, it works fine, but it gives off a weird error that gives low framerate.

    Error:
    "StackOverflowException: Max recursion depth of 100 has been exceeded. Consider increasing 'Recursion.defaultMaxDepth'.
    Ludiq.Recursion`1[T].Enter (T o) (at Ludiq.Core.Runtime/Utilities/Recursion.cs:27)
    Bolt.Flow.BeforeInvoke (Bolt.ControlOutput output, Bolt.Flow+RecursionNode recursionNode) (at Bolt.Flow.Runtime/Flow.cs:408)
    Bolt.Flow.Invoke (Bolt.ControlOutput output) (at Bolt.Flow.Runtime/Flow.cs:339)"

    Set Text is giving off the error
    EDIT: Fixed
     

    Attached Files:

    Last edited: Feb 20, 2021
  2. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    This is totally normal. You are in an update event loop and your units will execute from the Update Event unit at every frame. What you are doing, is an infinite loop inside of a frame.
    upload_2021-2-24_16-48-24.png
     

    Attached Files:

    Haneferd likes this.
  3. jasonasaad2

    jasonasaad2

    Joined:
    Nov 30, 2020
    Posts:
    51
    Thanks it worked.
     
    ericb_unity likes this.