Distance indicator size proportional to swingDistance (still not correct)

This commit is contained in:
2024-10-22 01:47:16 -07:00
parent 23bab7a3e1
commit 374355c291
5 changed files with 112 additions and 102 deletions

View File

@@ -2,18 +2,17 @@ using UnityEngine;
public class DistanceIndicator : MonoBehaviour
{
Teo player;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Teo player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
RectTransform rect = GetComponent<RectTransform>();
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, player.swingDistance*2);
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, player.swingDistance*2);
player= GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
}
// Update is called once per frame
void Update()
{
Debug.Log(player.swingDistance);
transform.localScale = new Vector3 (player.swingDistance*0.2F, player.swingDistance*0.2F, 1);
}
}

View File

@@ -1,90 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6743253301251978515
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7438228175666914604}
- component: {fileID: 3732086603579851193}
- component: {fileID: 4460286574818953559}
- component: {fileID: 8349812527292480333}
m_Layer: 5
m_Name: DistanceIndicator
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7438228175666914604
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6743253301251978515}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
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: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3732086603579851193
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6743253301251978515}
m_CullTransparentMesh: 1
--- !u!114 &4460286574818953559
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6743253301251978515}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -3951105813050061920, guid: 46817c0fa76c6a671b18883470b5daed, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &8349812527292480333
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6743253301251978515}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 23dc3f32eba4c9e5aad24589fdbfa30c, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: c4d4b8228002b32e89ba2545d2ace771
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: