RayCast Entfernt und schießen verbessert

This commit is contained in:
pbg2h23akl 2024-07-03 13:56:17 +02:00
parent 8b60b36e35
commit 89cfac816b
7 changed files with 62 additions and 219 deletions

View File

@ -1,5 +1,36 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &2733685271872555805
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 19647278204217505}
m_Layer: 0
m_Name: BulletSpawnpoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &19647278204217505
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2733685271872555805}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 1.168}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5950832400214244271}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3391868011099319290 --- !u!1 &3391868011099319290
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -294,6 +325,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 19647278204217505}
- {fileID: 4163468239720933169} - {fileID: 4163468239720933169}
- {fileID: 7059315404903924766} - {fileID: 7059315404903924766}
m_Father: {fileID: 4231050703702953731} m_Father: {fileID: 4231050703702953731}
@ -471,6 +503,18 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 5950832400214244271} m_TransformParent: {fileID: 5950832400214244271}
m_Modifications: m_Modifications:
- target: {fileID: 686265786403669914, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
propertyPath: m_LocalPosition.x
value: 0.499
objectReference: {fileID: 0}
- target: {fileID: 686265786403669914, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
propertyPath: m_LocalPosition.y
value: 0.7
objectReference: {fileID: 0}
- target: {fileID: 686265786403669914, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
propertyPath: m_LocalPosition.z
value: -0.166
objectReference: {fileID: 0}
- target: {fileID: 1313371464610265781, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} - target: {fileID: 1313371464610265781, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -0.06001303 value: -0.06001303

View File

@ -272,13 +272,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5432457483690072105} m_GameObject: {fileID: 5432457483690072105}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} m_LocalRotation: {x: 0, y: -0.7071068, z: 0.7071068, w: 0}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 3286218375903244322} m_Father: {fileID: 3286218375903244322}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} m_LocalEulerAnglesHint: {x: 90, y: 0, z: 180}
--- !u!198 &3511214472677508059 --- !u!198 &3511214472677508059
ParticleSystem: ParticleSystem:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -43,7 +43,7 @@ ParticleSystem:
serializedVersion: 8 serializedVersion: 8
lengthInSec: 0.1 lengthInSec: 0.1
simulationSpeed: 1 simulationSpeed: 1
stopAction: 2 stopAction: 1
cullingMode: 0 cullingMode: 0
ringBufferMode: 0 ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1} ringBufferLoopRange: {x: 0, y: 1}
@ -3821,7 +3821,7 @@ ParticleSystem:
LightsModule: LightsModule:
enabled: 1 enabled: 1
ratio: 1 ratio: 1
light: {fileID: 0} light: {fileID: 3050412642343233004, guid: ecc11f2cd73840b43ac860dbd8067281, type: 3}
randomDistribution: 1 randomDistribution: 1
color: 1 color: 1
range: 1 range: 1

View File

@ -1,37 +1,5 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &3929927056536112425
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2326864918050230340}
m_Layer: 0
m_Name: BulletSpawnpoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2326864918050230340
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3929927056536112425}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 686265786403669914}
m_Father: {fileID: 6798321073873421098}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6867957792503530889 --- !u!1 &6867957792503530889
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -222,7 +190,7 @@ Transform:
m_Children: m_Children:
- {fileID: 7042537997030239891} - {fileID: 7042537997030239891}
- {fileID: 1313371464610265781} - {fileID: 1313371464610265781}
- {fileID: 2326864918050230340} - {fileID: 686265786403669914}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 30.44, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 30.44, z: 0}
--- !u!114 &1169450665700565 --- !u!114 &1169450665700565
@ -238,7 +206,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
muzzle: {fileID: 0} muzzle: {fileID: 0}
spawnpoint: {fileID: 3929927056536112425} spawnpoint: {fileID: 0}
bullet: {fileID: 939049122039926632, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3} bullet: {fileID: 939049122039926632, guid: 5bd04146a95212e41bc2c52b7079e131, type: 3}
dataBullet: {fileID: 11400000, guid: cafd241bae342f446ae8141cc5d72daf, type: 2} dataBullet: {fileID: 11400000, guid: cafd241bae342f446ae8141cc5d72daf, type: 2}
reloadTime: 3 reloadTime: 3
@ -248,19 +216,11 @@ PrefabInstance:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 2326864918050230340} m_TransformParent: {fileID: 6798321073873421098}
m_Modifications: m_Modifications:
- target: {fileID: 430484790216468074, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: stopAction
value: 1
objectReference: {fileID: 0}
- target: {fileID: 430484790216468074, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: LightsModule.light
value:
objectReference: {fileID: 3050412642343233004, guid: ecc11f2cd73840b43ac860dbd8067281, type: 3}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0 value: 0.50000054
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
@ -268,7 +228,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
@ -276,15 +236,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: -0 value: 0.0000000037252894
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0.7071067 value: 0.70710677
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: -0 value: -0.0000000030267977
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3} - target: {fileID: 6557869798269101976, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
@ -302,10 +262,6 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: MuzzleParticalSystem value: MuzzleParticalSystem
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 8077938284314862731, guid: 0d96e9e78ab544a4a98b8af026c4d9de, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: [] m_RemovedGameObjects: []
m_AddedGameObjects: [] m_AddedGameObjects: []

View File

@ -1384,78 +1384,10 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 423185948905945774, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 666296827679288680, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 1409017717971667579, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 3230210169410262755, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 3391868011099319290, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3} - target: {fileID: 3391868011099319290, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Player value: Player
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3391868011099319290, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 3601559577021101208, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 4093775944364614034, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.x
value: 0.55560887
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.y
value: -0.403
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.z
value: 0.60068274
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.w
value: -0.6547129
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.x
value: 0.042114396
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.y
value: 0.753147
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.z
value: -0.048446175
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 1.022
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 262.066
objectReference: {fileID: 0}
- target: {fileID: 4163468239720933169, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 7.29
objectReference: {fileID: 0}
- target: {fileID: 4231050703702953731, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3} - target: {fileID: 4231050703702953731, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0 value: 0
@ -1496,78 +1428,8 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4731377471211230426, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3} m_RemovedComponents: []
propertyPath: m_Layer m_RemovedGameObjects: []
value: 10
objectReference: {fileID: 0}
- target: {fileID: 4972354890819608722, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5245801164585615012, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5842865707223673138, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5846198897390256284, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 6608350815154232110, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.x
value: -0.06001303
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.y
value: 0.68006015
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalPosition.z
value: -0.1801692
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8477437862324887214, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8948127678283011642, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
propertyPath: m_Layer
value: 10
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 5245801164585615012, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
m_RemovedGameObjects:
- {fileID: 4093775944364614034, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3} m_SourcePrefab: {fileID: 100100000, guid: abab2a81048fcb64ab6d31bc6bc8f529, type: 3}

View File

@ -7,23 +7,13 @@ using UnityEngine;
public class BulletScript : MonoBehaviour public class BulletScript : MonoBehaviour
{ {
public DataBullet dataBullet; public DataBullet dataBullet;
private float damage; private float damage;
private float speed; private float speed;
private int ammo; private int ammo;
public GameObject particalClash; public GameObject particalClash;
public float lifetime = 3f; public float lifetime = 3f;
private Rigidbody rb; private Rigidbody rb;
private Vector3 direction;
private float time = 0f; private float time = 0f;
private Ray ray;
private RaycastHit hit;
/// <summary> /// <summary>
/// Sobald life Time vorbei ist Destroy die Bullet. /// Sobald life Time vorbei ist Destroy die Bullet.
/// </summary> /// </summary>
@ -33,11 +23,6 @@ public class BulletScript : MonoBehaviour
GameObject.Destroy(this.gameObject); GameObject.Destroy(this.gameObject);
} }
} }
private void CheckForColliders(){
if(Physics.Raycast(ray, out hit)){ //wenn true wird durch out in variable hit ein RayCastHit gespeichert
direction = hit.point - transform.position;//Richtung in die, die Kugel fliegt
}
}
/// <summary> /// <summary>
/// clashPartical spawned clashPartical am EinschlagPunkt der Kugel. /// clashPartical spawned clashPartical am EinschlagPunkt der Kugel.
/// </summary> /// </summary>
@ -69,18 +54,13 @@ public class BulletScript : MonoBehaviour
rb = this.GetComponent<Rigidbody>(); rb = this.GetComponent<Rigidbody>();
Physics.IgnoreCollision(GetComponent<Collider>(),GameObject.Find("Player").GetComponent<Collider>()); Physics.IgnoreCollision(GetComponent<Collider>(),GameObject.Find("Player").GetComponent<Collider>());
ray = Camera.main.ViewportPointToRay(new Vector3(0.5f,0.5f,0f));
CheckForColliders();
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
rb.velocity = direction.normalized * speed; rb.velocity = transform.forward * speed;
die(lifetime); die(lifetime);
time += Time.deltaTime; time += Time.deltaTime;
} }

View File

@ -34,7 +34,7 @@ public class WeaponScript : MonoBehaviour
if(Input.GetKeyDown(KeyCode.Mouse0)){ if(Input.GetKeyDown(KeyCode.Mouse0)){
muzzle.gameObject.SetActive(true); muzzle.gameObject.SetActive(true);
//muzzle.Play(); //muzzle.Play();
Instantiate(bullet,spawnpoint.transform.position,transform.rotation); Instantiate(bullet,spawnpoint.transform.position,spawnpoint.transform.rotation);
ammo--; ammo--;
} }
}else{ }else{
@ -46,7 +46,8 @@ public class WeaponScript : MonoBehaviour
void Start() void Start()
{ {
ammo = dataBullet.ammo; ammo = dataBullet.ammo;
muzzle = spawnpoint.GetComponentInChildren<ParticleSystem>(); muzzle = GetComponentInChildren<ParticleSystem>();
spawnpoint = GameObject.Find("Player/PlayerView/BulletSpawnpoint");
} }
// Update is called once per frame // Update is called once per frame