diff --git a/Assets/Jacob Folder/ScriptRayHit.cs b/Assets/Jacob Folder/ScriptRayHit.cs index f762ce8..bd79548 100644 --- a/Assets/Jacob Folder/ScriptRayHit.cs +++ b/Assets/Jacob Folder/ScriptRayHit.cs @@ -43,6 +43,7 @@ public class ScriptRayHit : MonoBehaviour offset += (rayAngle * rayLength) - (rayAngle * hit.distance); //Debug.Log(hit.point); } + Vector3 smoothedPos = Vector3.Lerp(transform.position, new Vector3(((target.position.x - offset.x)*rayLength), (target.position.y - offset.y)*smoothSpeed/5, -65f), smoothSpeed * Time.fixedDeltaTime); float x = Mathf.Abs(target.position.x - smoothedPos.x); diff --git a/Assets/Scene 1 Assets/Movement.cs b/Assets/Scene 1 Assets/Movement.cs index c1670ad..424194f 100644 --- a/Assets/Scene 1 Assets/Movement.cs +++ b/Assets/Scene 1 Assets/Movement.cs @@ -20,7 +20,7 @@ public class Movement : MonoBehaviour public bool m_Grounded; // Whether or not the player is grounded. const float k_CeilingRadius = .2f; // Radius of the overlap circle to determine if the player can stand up private Rigidbody2D m_Rigidbody2D; - private bool m_FacingRight = true; // For determining which way the player is currently facing. + public bool m_FacingRight = true; // For determining which way the player is currently facing. public Vector3 m_Velocity = Vector3.zero; public static bool pause = false; private bool dj = false; diff --git a/Assets/Scenes/Jacob's Scene.unity b/Assets/Scenes/Jacob's Scene.unity index 3ffc1be..96050b1 100644 --- a/Assets/Scenes/Jacob's Scene.unity +++ b/Assets/Scenes/Jacob's Scene.unity @@ -1149,6 +1149,8 @@ MonoBehaviour: m_EditorClassIdentifier: controller: {fileID: 790075221} animator: {fileID: 0} + health: {fileID: 0} + healthBarAnimator: {fileID: 0} runSpeed: 40 --- !u!58 &790075218 CircleCollider2D: @@ -1229,6 +1231,7 @@ MonoBehaviour: m_CrouchSpeed: 0.4 m_MovementSmoothing: 0.05 m_AirControl: 1 + swimming: 0 m_WhatIsGround: serializedVersion: 2 m_Bits: 247 @@ -1236,6 +1239,7 @@ MonoBehaviour: m_CeilingCheck: {fileID: 772189788} m_CrouchDisableCollider: {fileID: 790075219} m_Grounded: 0 + m_FacingRight: 1 m_Velocity: {x: 0, y: 0, z: 0} OnLandEvent: m_PersistentCalls: @@ -2255,3 +2259,183 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 1.5036321, y: 1} m_EdgeRadius: 0 +--- !u!61 &1864841646449138439 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4636133840519531435} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 2.79, y: 6.9} + m_EdgeRadius: 0 +--- !u!1 &4636133840519531435 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5789802511012774584} + - component: {fileID: 1864841646449138439} + m_Layer: 8 + m_Name: Hitbox + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5789802511012774584 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4636133840519531435} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.191, y: -0.063, z: 0} + m_LocalScale: {x: 0.16666667, y: 0.16666667, z: 1} + m_Children: [] + m_Father: {fileID: 7026014452258301085} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!50 &7026014452258301083 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7026014452258301087} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 0.0001 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!4 &7026014452258301085 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7026014452258301087} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 20, y: 3.51, z: 0} + m_LocalScale: {x: 2, y: 2, z: 1} + m_Children: + - {fileID: 5789802511012774584} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &7026014452258301086 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7026014452258301087} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + 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: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 1027733709 + m_SortingLayer: 2 + m_SortingOrder: 0 + m_Sprite: {fileID: -5029764186598712489, guid: 1a0db7ae73c9e43ac856b25d6ad47dbc, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!1 &7026014452258301087 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7026014452258301085} + - component: {fileID: 7026014452258301086} + - component: {fileID: 7026014452258301083} + - component: {fileID: 7026014452258301088} + m_Layer: 8 + m_Name: Spoopy Ghoste (Jumpscare Warning) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &7026014452258301088 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7026014452258301087} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f19ade9cdbc8e314195b298d78e2f5c7, type: 3} + m_Name: + m_EditorClassIdentifier: + boxCollider: {fileID: 1864841646449138439} + swimSpeed: 5 + cat: {fileID: 790075215} + ball: 0 + mvt: {fileID: 0} diff --git a/Assets/booMovement.cs b/Assets/booMovement.cs new file mode 100644 index 0000000..6eb1f1b --- /dev/null +++ b/Assets/booMovement.cs @@ -0,0 +1,80 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class booMovement : MonoBehaviour +{ + private Transform player; + public BoxCollider2D boxCollider; + public float swimSpeed = .25f; + private Rigidbody2D rb; + private Vector2 movement = Vector2.zero; + private float sizeOffset = 1f; + public GameObject cat; + public bool ball; + public Movement mvt; + + void Start() + { + rb = this.GetComponent(); + boxCollider = this.GetComponent(); + sizeOffset = Random.Range(2f, 10f); + player = cat.transform; + + + //player = GameObject.FindWithTag("Player").transform; + if (player == null) + { + Debug.Log("Player not found! Make sure Seiden's Char Movement has a tag of Player!"); + } + } + + void Update() + { + if (Movement.pause) return; + //if (boxCollider.transform.x < cat.transform.x && m_FacingRight) + mvt = cat.GetComponent(); + ball = mvt.m_FacingRight; + + if ((transform.position.x < player.position.x && ball)||(transform.position.x > player.position.x && !ball)) + { + Debug.Log("Away"); + player = cat.transform; + Vector3 direction = player.position - transform.position; + movement = direction.normalized; + // Scale spirit size so they look like the swim like squid lol + float size = Mathf.Sin(Time.time * sizeOffset) * .25f + 1; + transform.localScale = new Vector3(size, size, 1); + } + } + + void FixedUpdate() + { + if (Movement.pause) return; + if ((transform.position.x < player.position.x && ball) || (transform.position.x > player.position.x && !ball)) + { + moveMe(movement); + } + else + { + noMoveMe(transform); + } + } + + private void OnTriggerEnter2D(Collider2D collision) + { + if (collision.tag == "Player") + { + collision.GetComponent().takeHit(); + } + } + + void moveMe(Vector2 direction) + { + rb.MovePosition(rb.position + direction * swimSpeed * Time.fixedDeltaTime); + } + void noMoveMe(Transform transform) + { + rb.MovePosition(new Vector2(transform.position.x, transform.position.y)); + } +} \ No newline at end of file diff --git a/Assets/booMovement.cs.meta b/Assets/booMovement.cs.meta new file mode 100644 index 0000000..3ac6e4b --- /dev/null +++ b/Assets/booMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f19ade9cdbc8e314195b298d78e2f5c7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: