Thanks for the tip sectuz
I've went an other way, as I added a Coroutine that disable autoaction (and active from forward as well) after x seconds.
General principle is :
Get the object that the raycast hit, get the vTriggerGenericAnimation component from that object (you can notice that the component is in the child of the object, so watch out for your hierarchy on this one) and active AutoAction & Active from forward.
After x seconds, we disable the AutoAction & Active from forward of that said object.
Here is the script updated.
//declare those variables in the #regionvariables of the vThirdPersonController
GameObject autoaction;
RaycastHit enableaction;
//add this code after the void Awake ()
void FixedUpdate ()
{
//are we running ?
if (isSprinting == true) {
//if we are running, then we raycast what we are running to
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out enableaction, 0.5f)) {
//transform the object that we've hit
autoaction = enableaction.transform.gameObject;
//activate the AutoAction & active from forward
autoaction.GetComponentInChildren<vActions.vTriggerGenericAction> ().autoAction = true;
autoaction.GetComponentInChildren<vActions.vTriggerGenericAction> ().activeFromForward = true;
//go to the coroutine to disable the previous actions
StartCoroutine (DisableAutoAction ());
}
}
}
//This coroutine disable the AutoAction and active From Forward after x seconds
IEnumerator DisableAutoAction ()
{
yield return new WaitForSeconds (0.5f);
autoaction.GetComponentInChildren<vActions.vTriggerGenericAction> ().autoAction = false;
autoaction.GetComponentInChildren<vActions.vTriggerGenericAction> ().activeFromForward = false;
}
So far, this is working fine, but I still got this error :
NullReferenceException: Object reference not set to an instance of an object
Invector.vCharacterController.vThirdPersonController.FixedUpdate () (at Assets/ASSETS/Invector-3rdPersonController/Basic Locomotion/Scripts/CharacterController/vThirdPersonController.cs:49)
It's still working with this, but getting rid of that error would be nice 😊