Thank you for your prompt reply, here is my CinematicControlRemover script, the enemy’s behavior is all correct. I did a bit testing, when I disabled the PlayerController script in Edit mode, then re-enable this script, this issue also occurs. Just wondering if any of you know any known situation could cause this issue, otherwise it could be my PlayerController script has some bugs which then I won’t borther you guys as that script is very to long, I’ll debug myself if it is problem of PlayerController script. Thank you all.
namespace RPG.Cinematics {
public class CinematicControlRemover : MonoBehaviour {
GameObject player;
private void Start() {
this.GetComponent<PlayableDirector>().played += DisableControl;
this.GetComponent<PlayableDirector>().stopped += EnableControl;
player = GameObject.FindWithTag("Player");
}
void DisableControl(PlayableDirector pd) {
player.GetComponent<ActionScheduler>().CancelCurrentAction();
player.GetComponent<PlayerController>().enabled = false;
}
void EnableControl(PlayableDirector pd) {
player.GetComponent<PlayerController>().enabled = true;
}
}
}
here is my ActionScheduler script.
namespace RPG.Core
{
public class ActionScheduler : MonoBehaviour
{
IAction currentAction;
public void StartAction(IAction newAction)
{
if (currentAction == newAction) return;
if (currentAction != null)
{
currentAction.CancelCurrentAction();
}
currentAction = newAction;
}
public void CancelCurrentAction()
{
StartAction(null);
}
}
}