From dd5b94f9ad62bf55e71af5e5329e223a75d427cf Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Mon, 11 Jan 2021 10:21:24 +0000 Subject: [PATCH] enemy slidey --- Assets/Prefabs/Enemy.prefab | 14 ++++++++++++++ Assets/Scripts/SlideSideways.cs | 23 +++++++++++++++++++++++ Assets/Scripts/SlideSideways.cs.meta | 11 +++++++++++ 3 files changed, 48 insertions(+) create mode 100644 Assets/Scripts/SlideSideways.cs create mode 100644 Assets/Scripts/SlideSideways.cs.meta diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index 4942de9..8a08123 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -16,6 +16,7 @@ GameObject: - component: {fileID: 2122656558574222561} - component: {fileID: -3971665732303992234} - component: {fileID: -4901459127090716512} + - component: {fileID: 1858863165099212332} m_Layer: 7 m_Name: Enemy m_TagString: Untagged @@ -151,3 +152,16 @@ MonoBehaviour: m_EditorClassIdentifier: xMin: -10.1 xMax: 10.1 +--- !u!114 &1858863165099212332 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea3f51bb4cd6c8146a185362df2fe451, type: 3} + m_Name: + m_EditorClassIdentifier: + _speedRange: {x: -5, y: 5} diff --git a/Assets/Scripts/SlideSideways.cs b/Assets/Scripts/SlideSideways.cs new file mode 100644 index 0000000..6a5970d --- /dev/null +++ b/Assets/Scripts/SlideSideways.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +public class SlideSideways : MonoBehaviour +{ + [SerializeField] private Vector2 _speedRange; + + private float _speed; + + private void Start() + { + var r = new Unity.Mathematics.Random((uint)(Time.time*1000f)); + _speed = r.NextFloat(_speedRange.x, _speedRange.y); + } + + private void LateUpdate() + { + transform.Translate(Vector3.right * _speed * Time.deltaTime); + } +} diff --git a/Assets/Scripts/SlideSideways.cs.meta b/Assets/Scripts/SlideSideways.cs.meta new file mode 100644 index 0000000..d1b513d --- /dev/null +++ b/Assets/Scripts/SlideSideways.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea3f51bb4cd6c8146a185362df2fe451 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: