Commit bfffc737 authored by 18김민수's avatar 18김민수

pathRenderer bug fix

parent 1d1cbe85
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 8684657376034186972}
- component: {fileID: 8684657376034186975}
- component: {fileID: 8684657376034186974}
- component: {fileID: 1874320887972760096}
m_Layer: 0
m_Name: PathCollider
m_TagString: Untagged
......@@ -92,3 +93,15 @@ CapsuleCollider:
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1874320887972760096
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8684657376034186961}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b0dc7c4faf7b54448ac8c3d23e40fb14, type: 3}
m_Name:
m_EditorClassIdentifier:
......@@ -1390,7 +1390,7 @@ MonoBehaviour:
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_UiScaleMode: 2
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
......@@ -3226,7 +3226,7 @@ AudioListener:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1661408487}
m_Enabled: 1
m_Enabled: 0
--- !u!20 &1661408489
Camera:
m_ObjectHideFlags: 0
......@@ -3598,7 +3598,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 3840, y: 2160}
m_SizeDelta: {x: 1920, y: 1080}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1751424970
MonoBehaviour:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PathCollider : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
var loc = transform.localPosition;
var _x = loc.x;
var _y = loc.y;
transform.localPosition = new Vector3(loc.x, loc.y, 0);
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: b0dc7c4faf7b54448ac8c3d23e40fb14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -23,7 +23,7 @@ public class PathRenderer : MonoBehaviour
// Start is called before the first frame update
void Start()
{
_originalPathColliderY = PathColliderPrefab.transform.localScale.y;
_originalPathColliderY = PathColliderPrefab.transform.localScale.y / 2;
_pathRenderer = GetComponent<LineRenderer>();
_ResetPaths();
......@@ -69,8 +69,8 @@ public class PathRenderer : MonoBehaviour
private void _DrawOnePath(Vector3 point)
{
_ResetPaths();
square.pathList[0] = transform.localPosition;
square.pathList[1] = transform.worldToLocalMatrix * point;
square.pathList[0] = transform.position;
square.pathList[1] = point;
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(0);
}
......@@ -79,8 +79,8 @@ public class PathRenderer : MonoBehaviour
{
_pathRenderer.positionCount = 2;
square.pathList.Clear();
square.pathList.Add(transform.localPosition);
square.pathList.Add(transform.localPosition);
square.pathList.Add(transform.position);
square.pathList.Add(transform.position);
_pathRenderer.SetPositions(square.pathList.ToArray());
for (int i = 0; i < transform.childCount; i++)
{
......@@ -96,7 +96,7 @@ public class PathRenderer : MonoBehaviour
}
else
{
square.pathList.Add(transform.worldToLocalMatrix * point);
square.pathList.Add(point);
_pathRenderer.positionCount = square.pathList.Count();
_pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(square.pathList.Count() - 2);
......@@ -109,7 +109,7 @@ public class PathRenderer : MonoBehaviour
_pathCollider.name = "PathCollider-" + n;
_pathCollider.tag = "path";
_pathCollider.transform.localScale = new Vector3(0.1f, _originalPathColliderY, 0);
_pathCollider.transform.localEulerAngles = new Vector3(90,
_pathCollider.transform.eulerAngles = new Vector3(90,
(float)Constants.RadianToDegree(Mathf.PI / 2 +
Mathf.Atan
(square.GetTangent(
......@@ -118,6 +118,6 @@ public class PathRenderer : MonoBehaviour
float _newY = square.GetNthPath(n).magnitude;
_pathCollider.transform.localScale = new Vector3(0.1f, _newY * _originalPathColliderY, 0);
_pathCollider.transform.localPosition = (square.pathList[n] + square.pathList[n + 1]) / 2;
_pathCollider.transform.position = (square.pathList[n] + square.pathList[n + 1]) / 2;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment