I´m trying to throw a arm to the player while the arm is rotating in the animation, but the arm doesn’t move correctly in the update
I do not know what is the problem
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
timer = Random.Range(minTime, maxTime);
animator.SetFloat("timelife", timer);
rightArm = GameObject.Find("RightArm").GetComponent<Transform>();
rightArmPos = rightArm.localPosition;
boss = GameObject.Find("Bossu2Real").GetComponent<BossBehaviour2>();
player = GameObject.Find("nave").GetComponent<PlayerBehaviour>();
animator.SetBool("isAttackingWithArms", true);
isAtackingWithRightArm = true;
float lifetime = 0.3f;
direction.Normalize();
rightArm.transform.position = rightArm.transform.position + direction * armSpeed;
Debug.Log("posicion" + rightArm.transform.position);
Debug.Log("Throwing arm");
animator.SetFloat("timelife", lifetime);
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
direction = rightArm.position - boss.transform.position;
direction.Normalize();
rightArm.transform.position = boss.transform.position + direction * armSpeed;
//rightArm.position = direction * armSpeed * Time.deltaTime;
timer -= Time.deltaTime;
Debug.Log("Brazo en movimiento// Arm in movement");
if (timer <= 0)
{
Debug.Log("He esperado el timer");
// Destroy(rightArm.gameObject, lifetime);
isAtackingWithRightArm = false;
rightArm.localPosition = new Vector3(1.655198f, -1.130143f,0);
animator.ResetTrigger("isAttackingWithRightArm");
animator.SetTrigger("idle");
}
}