Iamdoa hsd;lqk ,sov nfk gk apms;k kjdod

I was in the wrong keyboard format ;(
This commit is contained in:
Unknown committed 2022-02-24 20:15:38 -06:00
1 parent 76ae6428c0
commit 815bb4f6fa
2 files changed
+57 -18

No files matched your search

+42 -6
View File
@@ -8,26 +8,62 @@ public class ScriptRayHit : MonoBehaviour
public RaycastHit2D hit; public RaycastHit2D hit;
public Ray ray; public Ray ray;
private int counter; private int counter;
public Camera followCam;
public GameObject followCam;
public Camera staticCam; public Camera staticCam;
private bool cam = false; private bool cam = false;
[Range(0.5f, 10f)] public float smoothSpeed = 1f;
[Range(1, 10)] public float rayLength = 4f;
private float angleStep = 4;
public Transform target;
public Rigidbody2D rb;
private Vector3 offset;
private LayerMask layerMask;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
counter = 0; counter = 0;
layerMask = LayerMask.GetMask("Background");
} }
void FixedUpdate()
{
offset = Vector3.zero;
for (int i = 1; i <=angleStep; i++)
{
var rayAngle = Quaternion.AngleAxis((360f / angleStep) * i, target.forward) * target.up;
hit = Physics2D.Raycast(target.position, rayAngle, rayLength, layerMask);
if (hit)
{
offset += (rayAngle * rayLength) - (rayAngle * hit.distance);
}
//Vector3 smoothedPos = new Vector3((target.position.x - offset.x)*rayLength, target.position.y - offset.y, -1.3f);
Vector3 smoothedPos = Vector3.Lerp(transform.position, new Vector3((target.position.x - offset.x)*rayLength, target.position.y - offset.y, -100f), smoothSpeed * Time.fixedDeltaTime);
Debug.Log(smoothedPos);
followCam.transform.position = smoothedPos;
}
}
//Vector3 smoothedPos = Vector3.Lerp(transform.position, new Vector3((target.position.x - offset.x)*rayLength, target.position.y - offset.y, -1.3f), smoothSpeed * Time.fixedDeltaTime);
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
hit = Physics2D.Raycast(transform.position, transform.TransformDirection(Vector2.right), 4f);
/*hit = Physics2D.Raycast(transform.position, transform.TransformDirection(Vector2.right), 4f);
if (hit) if (hit)
{ {
Debug.Log(" Hit a wall "+ hit.collider.name); Debug.Log(" Hit a wall "+ hit.collider.name);
staticCam.enabled = true; Debug.Log(hit.distance);
followCam.enabled = false; //staticCam.enabled = true;
//followCam.enabled = false;
counter = 0; counter = 0;
cam = true; //cam = true;
} }
else if (cam && counter == 30) else if (cam && counter == 30)
{ {
@@ -37,7 +73,7 @@ public class ScriptRayHit : MonoBehaviour
cam = false; cam = false;
Debug.Log(""); Debug.Log("");
} }
counter++; counter++;*/
} }
+15 -12
View File
@@ -814,7 +814,7 @@ Transform:
- {fileID: 485861824} - {fileID: 485861824}
- {fileID: 38840433} - {fileID: 38840433}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &772189787 --- !u!1 &772189787
GameObject: GameObject:
@@ -891,8 +891,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1fd41423fac95444da8286db867308b4, type: 3} m_Script: {fileID: 11500000, guid: 1fd41423fac95444da8286db867308b4, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
followCam: {fileID: 1477085818} followCam: {fileID: 913520874}
staticCam: {fileID: 913520876} staticCam: {fileID: 913520876}
smoothSpeed: 1
rayLength: 2
target: {fileID: 913520877}
rb: {fileID: 790075220}
--- !u!114 &784188899 --- !u!114 &784188899
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -988,7 +992,6 @@ Transform:
- {fileID: 772189788} - {fileID: 772189788}
- {fileID: 1772079924} - {fileID: 1772079924}
- {fileID: 784188897} - {fileID: 784188897}
- {fileID: 1477085816}
m_Father: {fileID: 1330058645} m_Father: {fileID: 1330058645}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1539,7 +1542,7 @@ Transform:
m_Children: m_Children:
- {fileID: 790075216} - {fileID: 790075216}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1363037121 --- !u!1 &1363037121
GameObject: GameObject:
@@ -1634,9 +1637,9 @@ GameObject:
- component: {fileID: 1477085816} - component: {fileID: 1477085816}
- component: {fileID: 1477085818} - component: {fileID: 1477085818}
- component: {fileID: 1477085817} - component: {fileID: 1477085817}
m_Layer: 0 m_Layer: 2
m_Name: Char Cam m_Name: Char Cam
m_TagString: Untagged m_TagString: MainCamera
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
@@ -1649,11 +1652,11 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1477085815} m_GameObject: {fileID: 1477085815}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -1.21113} m_LocalPosition: {x: 0, y: 2.08, z: -1.21113}
m_LocalScale: {x: 2, y: 2, z: 1} m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 790075216} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!81 &1477085817 --- !u!81 &1477085817
AudioListener: AudioListener:
@@ -1670,7 +1673,7 @@ Camera:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1477085815} m_GameObject: {fileID: 1477085815}
m_Enabled: 1 m_Enabled: 0
serializedVersion: 2 serializedVersion: 2
m_ClearFlags: 1 m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
@@ -1689,8 +1692,8 @@ Camera:
near clip plane: 0.01 near clip plane: 0.01
far clip plane: 1000 far clip plane: 1000
field of view: 155 field of view: 155
orthographic: 0 orthographic: 1
orthographic size: 5 orthographic size: 6
m_Depth: 0 m_Depth: 0
m_CullingMask: m_CullingMask:
serializedVersion: 2 serializedVersion: 2