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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Why LeanTween Error (LeanTween.cs 1793: private static int maxTweens = 400) out of available spaces

Discussion in 'Scripting' started by tianjisuan07, Dec 11, 2015.

  1. tianjisuan07

    tianjisuan07

    Joined:
    Dec 11, 2015
    Posts:
    3
    "LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( 800 );"
    Why is there a mistake?How to solve?Tank you.
     
  2. tianjisuan07

    tianjisuan07

    Joined:
    Dec 11, 2015
    Posts:
    3
    How much is appropriate?
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    How much is appropriate?

    The amount you need.
     
    Kiwasi likes this.
  4. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Sounds like you're creating tweens in update. Show the code where you're calling LeanTween.
     
  5. ninja07

    ninja07

    Joined:
    Dec 11, 2015
    Posts:
    2
    yes ,you are right.
    code:
    Class Player:
    void Start () {
    obj1=(Transform)Instantiate (LifeBar [1], this.transform.position + new Vector3 (0, 2f, 0), Quaternion.identity);
    LifeBar2sc = obj1.GetComponent<LifeBar2> ();
    }
    void Update ()
    {
    LifeBar2sc.UpdateLife(Currentlife, m_maxlife);
    }

    Class LifeBar2:
    void Pad2( float value )
    {
    LeanTween.scaleX (blood [1].gameObject, value, 1f);
    }

    public void UpdateLife(float currentlife, float maxlife)
    {
    if (maxlife == 0)
    return;
    this.Pad1(currentlife / maxlife);
    this.Pad2 (currentlife / maxlife);
    m_transform.localScale = new Vector3(m_hscale, m_vscale, 1.0f);
    }

    I have change LeanTween.cs 1793 line:
    private static int maxTweens = 1600;
    At present, for the time being no error.Thank you for your help.
     
  6. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Changing maxTweens is not the right solution (it's a kludge at best)

    This is not how you should use LeanTween.

    Can you explain (in words) what it is you're wanting to achieve and I'll show how that should be done with LeanTween.
     
  7. ninja07

    ninja07

    Joined:
    Dec 11, 2015
    Posts:
    2
    I only use LeanTween achieve a Lifebar's tween,the Lifebar call LeanTween.scaleX (blood [1].gameObject, value, 1f)
    when Players injured
    like that:
    lifebar.png
    you can see the green bar when Players injured then i called LeanTween.scaleX (blood [1].gameObject, value, 1f) in the Update() ,that is my need achieve effect. THe LifeBar need Update per frame.
     
  8. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    If you're updaing the lifebar position every update then set the scale directly every frame and get rid of the LeanTween.

    LeanTween is not made to work like that.
     
  9. tianjisuan07

    tianjisuan07

    Joined:
    Dec 11, 2015
    Posts:
    3
    OK,I see.Tank you for your help.
     
    larku likes this.