Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / RangedAnimationController.cs
@Rackday Rackday on 21 Aug 935 bytes Project Added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;

public class RangedAnimationController : AnimationController
{
    [SerializeField] private GameObject bulletPrefab;
    [SerializeField] private float offSet;
    [SerializeField] private float bulletVelocity;
    public void EndBool(string name)
    {
        animator.SetBool(name, false);
        animationRunning = false;
    }

    public void Attack()
    {
        Debug.Log("Shoot");
        GameObject bullet = Instantiate(bulletPrefab, fsm.transform.position + (((fsm.target.transform.position - fsm.transform.position).normalized + new Vector3(0,0.5f,0)) * offSet), Quaternion.identity);
        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;
    }
}