Added Ray scanning

Adds ray scanning which detects walls and currently triggers / platforms as well, needs to be fixed but should be an easy layer fix.
This commit is contained in:
Unknown committed 2022-02-21 22:10:15 -06:00
1 parent 43e756be25
commit 5e594b144d
7 files changed
+1341 -20

No files matched your search

+14 -12
View File
@@ -19,31 +19,33 @@ public class WallTrigger : MonoBehaviour
// Update is called once per frame
void Update()
{
if (entered && counter >=150)
{
cam.transform.position -= moveCam;
cat.transform.position -= moveCat;
entered = false;
}
else
{
counter++;
}
counter++;
}
void OnTriggerEnter2D(Collider2D col)
{
if (!entered)
if (!entered && counter >= 120)
{
entered = true;
Debug.Log("Trigger detected");
//Debug.Log("Move Cam Right");
cam.transform.position += moveCam;
cat.transform.position += moveCat;
Debug.Log(counter);
counter = 0;
//PlayerMovement.ChangePos(1, 2);
}
else if (counter >= 120 && entered)
{
//Debug.Log("Moved cam left");
Debug.Log(counter);
cam.transform.position -= moveCam;
cat.transform.position -= moveCat;
entered = false;
counter = 0;
}
}
/*void Interact(Collider2D col, ){
+1213
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 63478eacf32fba646aeb1b1643a15418
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+60 -8
View File
@@ -390,7 +390,8 @@ GameObject:
m_Component:
- component: {fileID: 900854139}
- component: {fileID: 900854140}
m_Layer: 0
- component: {fileID: 900854141}
m_Layer: 5
m_Name: Platform_A
m_TagString: Untagged
m_Icon: {fileID: 0}
@@ -405,8 +406,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 900854138}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalPosition: {x: 5.5, y: 0, z: 0}
m_LocalScale: {x: 2.006309, y: 1.2821575, z: 1}
m_Children: []
m_Father: {fileID: 469248024}
m_RootOrder: 0
@@ -427,16 +428,67 @@ BoxCollider2D:
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
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 3.18, y: 3.09}
newSize: {x: 1.5, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 1
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!212 &900854141
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 900854138}
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: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 4749d35015666ea4fa9076540d768b0e, type: 3}
m_Color: {r: 0.735849, g: 0.735849, b: 0.735849, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 1
m_Size: {x: 1.5, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &978064013
GameObject:
m_ObjectHideFlags: 0
+30
View File
@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScriptRayHit : MonoBehaviour
{
public RaycastHit2D hit;
public Ray ray;
private int counter;
// Start is called before the first frame update
void Start()
{
counter = 0;
}
// Update is called once per frame
void Update()
{
hit = Physics2D.Raycast(transform.position, transform.TransformDirection(Vector2.right), 4f);
if (hit)
{
Debug.Log(" Hit a wall "+ hit.collider.name);
Debug.Log(counter);
}
counter++;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1fd41423fac95444da8286db867308b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: