Update interval>0 will make the Task using elapsedTime run slower than normal. For example: Task Wait(3 second) will wait very long if UpdateInterval=1
I must create my own Wait task, that using:
Time.time-startTime replace for elapsedTime
I think elapsedTime depend on Time.Deltatime, so it’s not good when Update interval>0
You are right. elapsedTime does indeed depend on Time.deltaTime. However the fact that the Wait Action for example takes longer is because with a higher UpdateInterval number, fewer graph (and also action) Update calls are made (instead of 1 Update call per-frame). The Wait Action of course, checks if the target wait value has been reached within its Update call. As such, the Wait action will finish the next time the Update call is made, which can be a few frames away (depending on how high the UpdateInterval is) and that makes it last longer since no Update call and thus no check to see if it has finished is made until that Update call is made.
Can you maybe please let me know how your custom Wait action is implemented to clarify?
I use “wait action” in patrol behaviour, The character stand at a waypoint for about 3 seconds before move to next point. For performance, The update interval will be increased for AI characters at far distance or in invisible view. The wait time in “custom interval update” may be longer than in the normal update time but should not too long because it will make the AI behaviour become worse.
The custom Wait action I made as below:
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category(“NCA”)]
public class NCA_Wait : ActionTask
{
public BBParameter waitTime = 1f;
public CompactStatus finishStatus = CompactStatus.Success;
float mStartTime;
bool mIsStarted;
//============
protected override string info
{
get { return string.Format(“Wait {0} sec.”, waitTime); }
}
//===============
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit()
{
mIsStarted = false;
I might be missing something here 🙂 I just tested your custom wait and the “official” wait with a value of 3 sec. wait and an update interval of 2 sec. as an example. Both actions worked exactly the same way, meaning that they both took equally longer than 3 sec. to finish since Update method is called only between those intervals.
Are those two (your custom one and the official one) different in your case?
Please let me know.
Thank you!
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.