During the challenge, I put the event trigger in the TakeAction function instead of the Shoot function and it doesn’t work that way. But with the MoveAction, it does work in the TakeAction function and I’m having a hard time figuring out what the difference is.
MoveAction is fairly straightforward. We move the character, all we need is for the IsWalking to be set to true, and then false when it’s over.
Our Shoot action uses a small state machine to cycle through the steps to be prepared to shoot. Raising the rifle, aiming, and finally shooting.
switch (state)
{
case State.Aiming:
Vector3 aimDir = (targetUnit.GetWorldPosition() - unit.GetWorldPosition()).normalized;
float rotateSpeed = 10f;
transform.forward = Vector3.Lerp(transform.forward, aimDir, Time.deltaTime * rotateSpeed);
break;
case State.Charging:
stateTimer = .1f;
break;
case State.Shooting:
if (canShootBullet)
{
Shoot();
canShootBullet = false;
}
break;
case State.Cooloff:
break;
}
It’s simply too soon to fire the weapon in the TakeAction method.
1 Like
Thank you Brian, that helps.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.