diff options
Diffstat (limited to 'JamHelper/Assets/JamUtils/FirstPersonCharacterController/Rigidbody/MoveByVelocity/Scripts/Player.cs')
-rw-r--r-- | JamHelper/Assets/JamUtils/FirstPersonCharacterController/Rigidbody/MoveByVelocity/Scripts/Player.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/JamHelper/Assets/JamUtils/FirstPersonCharacterController/Rigidbody/MoveByVelocity/Scripts/Player.cs b/JamHelper/Assets/JamUtils/FirstPersonCharacterController/Rigidbody/MoveByVelocity/Scripts/Player.cs new file mode 100644 index 0000000..0e86a96 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FirstPersonCharacterController/Rigidbody/MoveByVelocity/Scripts/Player.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace JamUtils +{ + + public class Player : MonoBehaviour + { + [SerializeField] private GameObject m_Bullet; + + private FPSCharacterController m_Controller; + + private void Awake() + { + m_Controller = GetComponent<FPSCharacterController>(); + } + + private void Start() + { + m_Controller.shootTarget = ShootTarget; + m_Controller.checkHit = CheckHit; + } + + bool CheckHit(RaycastHit hit) + { + return true; + } + + void ShootTarget(Vector3 target, Transform muzzle) + { + GameObject go = GameObject.Instantiate(m_Bullet); + go.transform.position = muzzle.position; + go.GetComponent<Rigidbody>().velocity = (target - muzzle.position).normalized * 100; + } + + } + +} |