add some extra assets FX and SFX
This commit is contained in:
45
Assets/PixPlays/Components/Scripts/Character.cs
Normal file
45
Assets/PixPlays/Components/Scripts/Character.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public class Character : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Animator _Anim;
|
||||
[SerializeField] BindingPoints _BindingPoints;
|
||||
[SerializeField] Transform _Target;
|
||||
|
||||
private AnimatorOverrideController _overrideController;
|
||||
public BindingPoints BindingPoints => _BindingPoints;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_Anim.runtimeAnimatorController != null)
|
||||
{
|
||||
_overrideController = new AnimatorOverrideController(_Anim.runtimeAnimatorController);
|
||||
_Anim.runtimeAnimatorController = _overrideController;
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAnimation(string clipId,AnimationClip clip)
|
||||
{
|
||||
if (_overrideController != null)
|
||||
{
|
||||
_overrideController[clipId] = clip;
|
||||
_Anim.SetTrigger("Play");
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetTarget()
|
||||
{
|
||||
Vector3 direction = (_Target.position - transform.position).normalized;
|
||||
Ray ray = new Ray(transform.position, direction);
|
||||
RaycastHit hit;
|
||||
if(Physics.Raycast(ray,out hit,100))
|
||||
{
|
||||
return hit.point;
|
||||
}
|
||||
return _Target.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user