Hello. I ran into a problem while working on a code that was increasing the number of SPs.
I made the code.
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Naninovel;
public class SP_Bar : MonoBehaviour {
private void Update()
{
var variableManager = Engine.GetService<ICustomVariableManager>();
variableManager.TryGetVariableValue<float>("enemy_SP", out var enemy_SP);
variableManager.TryGetVariableValue<bool>("SP_stop", out var SP_stop);
RectTransform rectTran = gameObject.GetComponent<RectTransform>();
rectTran.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1000/100*enemy_SP);
if (SP_stop==true){
enemy_SP += 0.3f * Time.deltaTime;
if (enemy_SP >= 100f){
enemy_SP = 100f;
}
}
variableManager.TrySetVariableValue("enemy_SP", enemy_SP);
}
}
Then, I found that the SP increases when using skip, but the SP does not increase when the skip is turned off.
I think Time.delta Time is the problem.
Is there a way to solve this problem using Time.deltaTime?