1) Refactor Project Architecture 2) Add Assets 3) Change Prefabs 4) Change Input Method (now using PlayerInput Component) 5) Add Weapon Prefab & Simple Script with Shooting() 6) Add Menu Scene & two btn functions: QuitGame() & PlayGame()
18 lines
435 B
C#
18 lines
435 B
C#
using UnityEngine;
|
|
|
|
public class Weapon : MonoBehaviour
|
|
{
|
|
// [SerializeField] private float damage = 10f;
|
|
[SerializeField] private float range = 100f;
|
|
[SerializeField] protected Camera mainCam;
|
|
|
|
public void Shooting()
|
|
{
|
|
RaycastHit hit;
|
|
if (Physics.Raycast(mainCam.transform.position, mainCam.transform.forward, out hit, range))
|
|
{
|
|
Debug.Log(hit.transform.name);
|
|
}
|
|
}
|
|
}
|