I'm tired, I'm sleeping

Hey if someone could expand on this that'd be great I think
This commit is contained in:
Unknown committed 2022-02-26 00:58:16 -06:00
1 parent 8539237c26
commit efd8a2bc3f
5 files changed
+4192 -26

No files matched your search

+5 -3
View File
@@ -11,6 +11,7 @@ public class Ceiling_Trigger : MonoBehaviour
[Range (1f,25f)]public float camOffset = 10f; [Range (1f,25f)]public float camOffset = 10f;
[Range (1f,15f)] public float catOffset = 5f; [Range (1f,15f)] public float catOffset = 5f;
[Range(5, 180)] public int countOffset = 10; [Range(5, 180)] public int countOffset = 10;
private LayerMask layerMask;
private Vector3 moveCam; private Vector3 moveCam;
private Vector3 moveCat; private Vector3 moveCat;
@@ -19,6 +20,7 @@ public class Ceiling_Trigger : MonoBehaviour
{ {
moveCam = new Vector3(0, camOffset, 0); moveCam = new Vector3(0, camOffset, 0);
moveCat = new Vector3(0, catOffset, 0); moveCat = new Vector3(0, catOffset, 0);
layerMask = LayerMask.GetMask("Player");
} }
// Update is called once per frame // Update is called once per frame
@@ -29,14 +31,14 @@ public class Ceiling_Trigger : MonoBehaviour
void OnTriggerEnter2D(Collider2D col) void OnTriggerEnter2D(Collider2D col)
{ {
float ye = cat.transform.position.y; float ye = cat.transform.position.y;
float goaly = box.transform.localPosition.y; float goaly = box.transform.position.y;
if (ye < goaly && counter >= countOffset) if ((ye < goaly && counter >= countOffset))
{ {
cam.transform.position += moveCam; cam.transform.position += moveCam;
cat.transform.position += moveCat; cat.transform.position += moveCat;
counter = 0; counter = 0;
} }
else if (ye >= goaly && counter > countOffset) else if ((ye >= goaly && counter > countOffset))
{ {
cam.transform.position -= moveCam; cam.transform.position -= moveCam;
cat.transform.position -= moveCat; cat.transform.position -= moveCat;
+50
View File
@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WorkingWallTrigger : MonoBehaviour
{
public GameObject cam;
public GameObject cat;
public BoxCollider2D box;
private int counter = 0;
[Range(1f, 25f)] public float camOffset = 10f;
[Range(1f, 15f)] public float catOffset = 5f;
[Range(5, 180)] public int countOffset = 10;
private Vector3 moveCam;
private Vector3 moveCat;
private LayerMask layerMask;
// Start is called before the first frame update
void Start()
{
moveCam = new Vector3(camOffset, 0, 0);
moveCat = new Vector3(catOffset, 0, 0);
layerMask = LayerMask.GetMask("Player");
}
// Update is called once per frame
void Update()
{
counter++;
}
void OnTriggerEnter2D(Collider2D col)
{
float ye = cat.transform.position.y;
float goaly = box.transform.localPosition.y;
if (ye < goaly && counter >= countOffset && col.IsTouchingLayers(layerMask))
{
cam.transform.position -= moveCam;
cat.transform.position -= moveCat;
counter = 0;
}
else if (ye >= goaly && counter > countOffset && col.IsTouchingLayers(layerMask))
{
cam.transform.position += moveCam;
cat.transform.position += moveCat;
counter = 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9800bd0db2e93148b45782870fed8ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+5 -3
View File
@@ -24,6 +24,8 @@ public class NPC : MonoBehaviour
{ {
delay = Random.Range(minDelay, maxDelay); delay = Random.Range(minDelay, maxDelay);
horizontalMove = horizontalMove * runSpeed; horizontalMove = horizontalMove * runSpeed;
leftBound += controller.transform.localPosition.x;
rightBound -= controller.transform.localPosition.x;
} }
// Update is called once per frame // Update is called once per frame
@@ -42,10 +44,10 @@ public class NPC : MonoBehaviour
animator.SetBool("Airborne", !controller.m_Grounded); animator.SetBool("Airborne", !controller.m_Grounded);
} }
elapsed += Time.deltaTime; elapsed += Time.deltaTime;
if(transform.position.x > rightBound) { if(transform.localPosition.x > rightBound) {
horizontalMove = -1 * runSpeed; horizontalMove = -1 * runSpeed;
} } else
if(transform.position.x < leftBound) { if(transform.localPosition.x < leftBound) {
horizontalMove = runSpeed; horizontalMove = runSpeed;
} }
} }
File diff suppressed because it is too large. Load diff