blob: 0e86a960ee43a35b71951330d43e83cad935e583 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
}
}
|