Fixed RayCasts

This commit is contained in:
2022-04-18 15:42:54 +07:00
parent 2fd9694679
commit 4bc5cb5ed2
3 changed files with 5264 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,8 @@ public class scr_CharacterController : MonoBehaviour
public float range = 100f; public float range = 100f;
public Camera fpsCam; public Camera fpsCam;
public ParticleSystem muzzleFlash;
public GameObject impactEffect;
private void Awake() private void Awake()
{ {
defaultInput = new DefaultInput(); defaultInput = new DefaultInput();
@ -88,7 +89,7 @@ public class scr_CharacterController : MonoBehaviour
characterController = GetComponent<CharacterController>(); characterController = GetComponent<CharacterController>();
cameraHeight = cameraHolder.localPosition.y; cameraHeight = cameraHolder.localPosition.y;
if (currentWeapon) if (currentWeapon)
{ {
currentWeapon.Initialise(this); currentWeapon.Initialise(this);
@ -110,10 +111,19 @@ public class scr_CharacterController : MonoBehaviour
void Shoot() void Shoot()
{ {
muzzleFlash.Play();
RaycastHit hit; RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{ {
Debug.Log(hit.transform.name); Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{
target.TakeDamage(damage);
}
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
} }
} }

View File

@ -614,7 +614,11 @@ PlayerSettings:
webGLLinkerTarget: 1 webGLLinkerTarget: 1
webGLThreadsSupport: 0 webGLThreadsSupport: 0
webGLWasmStreaming: 0 webGLWasmStreaming: 0
scriptingDefineSymbols: {} scriptingDefineSymbols:
1: CROSS_PLATFORM_INPUT
4: CROSS_PLATFORM_INPUT;MOBILE_INPUT
7: CROSS_PLATFORM_INPUT;MOBILE_INPUT
14: MOBILE_INPUT
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: {} scriptingBackend: {}
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}
@ -712,5 +716,5 @@ PlayerSettings:
organizationId: unity_9asvqbkpr8e5lq organizationId: unity_9asvqbkpr8e5lq
cloudEnabled: 0 cloudEnabled: 0
enableNativePlatformBackendsForNewInputSystem: 1 enableNativePlatformBackendsForNewInputSystem: 1
disableOldInputManagerSupport: 1 disableOldInputManagerSupport: 0
legacyClampBlendShapeWeights: 0 legacyClampBlendShapeWeights: 0