From b8abd15fd2c3b83429e73aa2ef610f57cab2dead Mon Sep 17 00:00:00 2001 From: Soulaha Balde Date: Sat, 14 May 2022 16:05:45 -0400 Subject: [PATCH] Added trail for better feel on bullets Bullets come out of cannon barrel --- Assets/Art/Materials/mat_trail.mat | 3 + Assets/Art/Materials/mat_trail.mat.meta | 3 + Assets/Prefabs/Player.prefab | 19 +---- Assets/Prefabs/Projectile.prefab | 100 ++++++++++++++++++++++++ Assets/Scripts/CannonScript.cs | 2 +- 5 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 Assets/Art/Materials/mat_trail.mat create mode 100644 Assets/Art/Materials/mat_trail.mat.meta diff --git a/Assets/Art/Materials/mat_trail.mat b/Assets/Art/Materials/mat_trail.mat new file mode 100644 index 0000000..4452d30 --- /dev/null +++ b/Assets/Art/Materials/mat_trail.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c265bf2e94c629fe2ba804aea7a08cdfdb59e47b2bbc6a0bd57f19ecab2447bb +size 3504 diff --git a/Assets/Art/Materials/mat_trail.mat.meta b/Assets/Art/Materials/mat_trail.mat.meta new file mode 100644 index 0000000..c5d3d39 --- /dev/null +++ b/Assets/Art/Materials/mat_trail.mat.meta @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46aef8acedacfac67e586ecb122984b45641543888639d45ff7fc506253ff156 +size 188 diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index e2e5a56..7165ce2 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -183,22 +183,6 @@ MonoBehaviour: m_Calls: [] m_ActionId: 61ddf11f-3478-4887-ab86-0ead8dde336f m_ActionName: UI/TrackedDeviceOrientation - - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 3117915759359451286} - m_TargetAssemblyTypeName: PlayerController, Assembly-CSharp - m_MethodName: OnUpgrade - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 - m_ActionId: dbe4eda4-74d0-47d3-b2d1-c8292faa8b62 - m_ActionName: Player/UpgradeTest[/Keyboard/r] m_NeverAutoSwitchControlSchemes: 0 m_DefaultControlScheme: m_DefaultActionMap: Player @@ -222,6 +206,7 @@ MonoBehaviour: cannonForce: 1000 fireRate: 0.5 fireTimer: 0 + damage: 1 --- !u!1 &6969840675949508920 GameObject: m_ObjectHideFlags: 0 @@ -315,7 +300,7 @@ BoxCollider: m_GameObject: {fileID: 6969840675949508920} m_Material: {fileID: 0} m_IsTrigger: 0 - m_Enabled: 1 + m_Enabled: 0 serializedVersion: 2 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefabs/Projectile.prefab b/Assets/Prefabs/Projectile.prefab index 0552853..37364fb 100644 --- a/Assets/Prefabs/Projectile.prefab +++ b/Assets/Prefabs/Projectile.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 8824810498392835647} - component: {fileID: 1596552820235563576} - component: {fileID: -5096460011673770898} + - component: {fileID: 8618525506095844415} m_Layer: 0 m_Name: Projectile m_TagString: Untagged @@ -128,3 +129,102 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: lifeTime: 1 +--- !u!96 &8618525506095844415 +TrailRenderer: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5630905120393344806} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 0 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 0 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: ee1ce0afe992adc458acbbc4cdff6ab2, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Time: 0.02 + m_Parameters: + serializedVersion: 3 + widthMultiplier: 0.25 + widthCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + colorGradient: + serializedVersion: 2 + key0: {r: 0.740566, g: 0.9948123, b: 1, a: 1} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + numCornerVertices: 0 + numCapVertices: 0 + alignment: 0 + textureMode: 0 + shadowBias: 0.5 + generateLightingData: 1 + m_MinVertexDistance: 0.1 + m_Autodestruct: 0 + m_Emitting: 1 diff --git a/Assets/Scripts/CannonScript.cs b/Assets/Scripts/CannonScript.cs index f4f8f52..2f35a69 100644 --- a/Assets/Scripts/CannonScript.cs +++ b/Assets/Scripts/CannonScript.cs @@ -30,7 +30,7 @@ public class CannonScript : MonoBehaviour if(firing && !EventSystem.current.IsPointerOverGameObject()){ fireTimer += Time.deltaTime; if(fireTimer >= fireRate){ - GameObject proj = Instantiate(projectile, transform.position, cannon.transform.rotation); + GameObject proj = Instantiate(projectile, cannon.transform.position, cannon.transform.rotation); proj.GetComponent().SetDamage(damage); proj.GetComponent().AddForce(cannonForce * lookDir, ForceMode.Impulse); fireTimer = 0;