shoot und reload auf knöpfe vom InputManager angepasst

This commit is contained in:
pbg2h23akl 2024-08-21 12:17:02 +02:00
parent 7c2d4c46d4
commit 4982142557
2 changed files with 76 additions and 4 deletions

View File

@ -123,6 +123,74 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &461782422
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 461782425}
- component: {fileID: 461782424}
- component: {fileID: 461782423}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &461782423
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 461782422}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &461782424
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 461782422}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &461782425
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 461782422}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &675150769 --- !u!1 &675150769
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1502,5 +1570,6 @@ SceneRoots:
- {fileID: 1513164528} - {fileID: 1513164528}
- {fileID: 1124830199} - {fileID: 1124830199}
- {fileID: 829478755} - {fileID: 829478755}
- {fileID: 6175215765042975734}
- {fileID: 1253446898} - {fileID: 1253446898}
- {fileID: 6175215765042975734}
- {fileID: 461782425}

View File

@ -11,6 +11,8 @@ public class WeaponScript : MonoBehaviour
public DataBullet dataBullet; public DataBullet dataBullet;
public UI_Manager uI_Manager; public UI_Manager uI_Manager;
private InputManagerScript inputManagerScript;
private int ammo; private int ammo;
private bool isReloading = false; private bool isReloading = false;
private float time = 0; private float time = 0;
@ -21,7 +23,7 @@ public class WeaponScript : MonoBehaviour
public float schussInterval; public float schussInterval;
private float delay = 0; private float delay = 0;
public void checkReload(){ public void checkReload(){
if(ammo == 0){ if(ammo == 0 || Input.GetKeyDown(inputManagerScript.getReload())){
isReloading = true; isReloading = true;
} }
if(isReloading){ if(isReloading){
@ -35,8 +37,8 @@ public class WeaponScript : MonoBehaviour
} }
} }
public void shoot(){ public void shoot(){
if(ammo != 0 && delayOver){ if(!isReloading && delayOver){
if(Input.GetKeyDown(KeyCode.Mouse0)){ if(Input.GetKeyDown(inputManagerScript.getShoot())){
muzzle.gameObject.SetActive(true); muzzle.gameObject.SetActive(true);
//muzzle.Play(); //muzzle.Play();
Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation); Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
@ -61,6 +63,7 @@ public class WeaponScript : MonoBehaviour
muzzle = GetComponentInChildren<ParticleSystem>(); muzzle = GetComponentInChildren<ParticleSystem>();
spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint"); spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint");
uI_Manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<UI_Manager>(); uI_Manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<UI_Manager>();
inputManagerScript = GameObject.Find("InputManager").GetComponent<InputManagerScript>();
} }
// Update is called once per frame // Update is called once per frame