Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / RangedAnimationController.cs
@Rackday Rackday on 21 Aug 935 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Animations;
  5. public class RangedAnimationController : AnimationController
  6. {
  7. [SerializeField] private GameObject bulletPrefab;
  8. [SerializeField] private float offSet;
  9. [SerializeField] private float bulletVelocity;
  10. public void EndBool(string name)
  11. {
  12. animator.SetBool(name, false);
  13. animationRunning = false;
  14. }
  15. public void Attack()
  16. {
  17. Debug.Log("Shoot");
  18. GameObject bullet = Instantiate(bulletPrefab, fsm.transform.position + (((fsm.target.transform.position - fsm.transform.position).normalized + new Vector3(0,0.5f,0)) * offSet), Quaternion.identity);
  19. bullet.GetComponent<Rigidbody>().velocity = bulletVelocity * new Vector3(fsm.target.transform.position.x - fsm.transform.position.x, 0 , fsm.target.transform.position.z - fsm.transform.position.z).normalized;
  20. }
  21. }