Hi there,
I wanted to use MoveTowards on my script on Naninovel so I could change my EXPbar gradually, unfortunately, I can only use Random and CalculateProgress
So I tried to add this function as you explained in the doc:
Hi, Can you please clarify how you're using this function in scripts and what you expect to happen.
Well I say that @set EXPbar(AKA the value of the bar)=MoveTowards(0, charaEXP,charaEXPamount)
charaEXP is the EXP the character currently has
and charaEXPamount is the EXP the character needs to level up!
What I expect to happen is for the bar to go gradually from 0 to the charaEXP it currently has BUT it can't pass the charaEXPamount
It says to me that that function doesn't exist though
Not sure why it's not recognizing the function. Check the inventory example project, there are custom functions used there and they're working fine, afaik. By the way, I'd suggest implementing the UI logic in C# (or visual scripting), as naninovel scripts are not really intended for that kind of stuff. You can set the exp custom variable in naninovel script and react accordingly (update the UI properties and run the required animations) in C#.
Not sure why it's not recognizing the function. Check the inventory example project, there are custom functions used there and they're working fine, afaik. By the way, I'd suggest implementing the UI logic in C# (or visual scripting), as naninovel scripts are not really intended for that kind of stuff. You can set the exp value custom variable in naninovel script and react accordingly (update the UI value with the required animations) in C#.
Thank you so much! I'm not very good with C# coding but I think I'll do that! :) Thank you for the help!! :)
Not sure why it's not recognizing the function. Check the inventory example project, there are custom functions used there and they're working fine, afaik. By the way, I'd suggest implementing the UI logic in C# (or visual scripting), as naninovel scripts are not really intended for that kind of stuff. You can set the exp custom variable in naninovel script and react accordingly (update the UI properties and run the required animations) in C#.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Naninovel;
using Naninovel.UI;
public class EXPbaranimation : MonoBehaviour
{
public Slider EXPbar;
// Update is called once per frame
void Update()
{
var variableManager = Engine.GetService<ICustomVariableManager>();
variableManager.TryGetVariableValue<float>("charaEXP", out var charaEXP);
variableManager.TryGetVariableValue<float>("charaEXPamount", out var charaEXPamount);
EXPbar.maxValue = charaEXPamount;
EXPbar.value = Mathf.MoveTowards(EXPbar.value, charaEXP, 10f * Time.deltaTime);
}
}
I wrote this code yet I strangely got those 2 errors, I don't understand them at all :(