From da9121462f1844f637c89f886411443b62219939 Mon Sep 17 00:00:00 2001 From: klikev Date: Sun, 16 Jun 2024 13:50:01 +0200 Subject: [PATCH] RayCast MaximumRange added // Able to shoot in the air --- .../Assets/PrefabsKevin/Gun/Gun.prefab | 54 +++++++++++++++++++ .../Assets/Scenes/KevinSceneGun.unity | 20 +++++++ .../{BulletMoving.cs => BulletScript.cs} | 4 +- ...letMoving.cs.meta => BulletScript.cs.meta} | 0 .../ScriptableObjects/DataBullet.asset | 2 +- 5 files changed, 77 insertions(+), 3 deletions(-) rename Plunderblock/Assets/Scripts/ScriptsKevin/{BulletMoving.cs => BulletScript.cs} (90%) rename Plunderblock/Assets/Scripts/ScriptsKevin/{BulletMoving.cs.meta => BulletScript.cs.meta} (100%) diff --git a/Plunderblock/Assets/PrefabsKevin/Gun/Gun.prefab b/Plunderblock/Assets/PrefabsKevin/Gun/Gun.prefab index fcf1fc0..1803284 100644 --- a/Plunderblock/Assets/PrefabsKevin/Gun/Gun.prefab +++ b/Plunderblock/Assets/PrefabsKevin/Gun/Gun.prefab @@ -31,6 +31,59 @@ Transform: m_Children: [] m_Father: {fileID: 6798321073873421098} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &6867957792503530889 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7042537997030239891} + - component: {fileID: 7952171964233530059} + m_Layer: 0 + m_Name: MaxRayCastRange + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7042537997030239891 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6867957792503530889} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0.9942074, z: -0, w: 0.10747881} + m_LocalPosition: {x: 27.92, y: 0, z: -19.1} + m_LocalScale: {x: 1, y: 100, z: 100} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6798321073873421098} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &7952171964233530059 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6867957792503530889} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &7971593296632072563 GameObject: m_ObjectHideFlags: 0 @@ -166,6 +219,7 @@ Transform: m_LocalScale: {x: 0.9699999, y: 0.3, z: 0.31} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 7042537997030239891} - {fileID: 1313371464610265781} - {fileID: 2326864918050230340} m_Father: {fileID: 0} diff --git a/Plunderblock/Assets/Scenes/KevinSceneGun.unity b/Plunderblock/Assets/Scenes/KevinSceneGun.unity index 9693a06..b4c46d8 100644 --- a/Plunderblock/Assets/Scenes/KevinSceneGun.unity +++ b/Plunderblock/Assets/Scenes/KevinSceneGun.unity @@ -1366,6 +1366,26 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 7042537997030239891, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7042537997030239891, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} + propertyPath: m_LocalScale.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7042537997030239891, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} + propertyPath: m_LocalScale.z + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7952171964233530059, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} + propertyPath: m_IsTrigger + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7952171964233530059, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} + propertyPath: m_ProvidesContacts + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8363807481264483936, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} propertyPath: m_Name value: Gun diff --git a/Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs b/Plunderblock/Assets/Scripts/ScriptsKevin/BulletScript.cs similarity index 90% rename from Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs rename to Plunderblock/Assets/Scripts/ScriptsKevin/BulletScript.cs index 9ca7853..70554eb 100644 --- a/Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs +++ b/Plunderblock/Assets/Scripts/ScriptsKevin/BulletScript.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class BulletMoving : MonoBehaviour +public class BulletScript : MonoBehaviour { public DataBullet dataBullet; @@ -40,7 +40,7 @@ public class BulletMoving : MonoBehaviour // Update is called once per frame void Update() { - rb.velocity = direction * dataBullet.speed; + rb.velocity = direction.normalized * dataBullet.speed; die(lifetime); time += Time.deltaTime; } diff --git a/Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs.meta b/Plunderblock/Assets/Scripts/ScriptsKevin/BulletScript.cs.meta similarity index 100% rename from Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs.meta rename to Plunderblock/Assets/Scripts/ScriptsKevin/BulletScript.cs.meta diff --git a/Plunderblock/Assets/Scripts/ScriptsKevin/ScriptableObjects/DataBullet.asset b/Plunderblock/Assets/Scripts/ScriptsKevin/ScriptableObjects/DataBullet.asset index 6ff9656..b8c5c7a 100644 --- a/Plunderblock/Assets/Scripts/ScriptsKevin/ScriptableObjects/DataBullet.asset +++ b/Plunderblock/Assets/Scripts/ScriptsKevin/ScriptableObjects/DataBullet.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_Name: DataBullet m_EditorClassIdentifier: damage: 10 - speed: 5 + speed: 10 ammo: 4