feat (orbiting spere): create a sphere that orbiting around thats mimic the living root behaviour
This commit is contained in:
@@ -6,16 +6,29 @@ public class RootCrawler : MonoBehaviour
|
||||
public Transform target;
|
||||
public float maxHeight;
|
||||
public float crawlingSpeed;
|
||||
public float radius = 0.5f;
|
||||
public float rotationSpeed = 5f;
|
||||
|
||||
private float height = 0f;
|
||||
private float angle = 0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
void Update()
|
||||
{
|
||||
if (target == null)
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
height += Time.deltaTime * crawlingSpeed;
|
||||
height = Mathf.Clamp(height, 0f, maxHeight);
|
||||
transform.position = target.position + Vector3.up * height;
|
||||
|
||||
angle += Time.deltaTime * rotationSpeed;
|
||||
|
||||
float x = Mathf.Cos(angle) * radius;
|
||||
float z = Mathf.Sin(angle) * radius;
|
||||
|
||||
Vector3 basePos = target.position;
|
||||
Vector3 offset = new Vector3(x, height - 0.8f, z);
|
||||
|
||||
transform.position = basePos + offset;
|
||||
Debug.DrawLine(target.position, transform.position, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public class SlowdownArea : MonoBehaviour
|
||||
public float maxSlow;
|
||||
public float slowSpeed;
|
||||
public float timer;
|
||||
public GameObject playerBody;
|
||||
|
||||
[Header("Root Crawler")]
|
||||
public GameObject rootCrawlerPrefab;
|
||||
@@ -26,9 +27,10 @@ public class SlowdownArea : MonoBehaviour
|
||||
jump.JumpForce = 1.5f;
|
||||
isInZone = true;
|
||||
if (currentCrawler == null) {
|
||||
currentCrawler = Instantiate(rootCrawlerPrefab, player.transform.position, Quaternion.identity);
|
||||
RootCrawler crawler = currentCrawler.GetComponent<RootCrawler>();
|
||||
crawler.target = player.transform;
|
||||
currentCrawler = Instantiate(rootCrawlerPrefab);
|
||||
|
||||
RootCrawler crawler = currentCrawler.GetComponent<RootCrawler>();
|
||||
crawler.target = playerBody.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7919538883693841265}
|
||||
- component: {fileID: 344069317130189608}
|
||||
- component: {fileID: 4811596309560135411}
|
||||
- component: {fileID: 8977163302937735702}
|
||||
m_Layer: 0
|
||||
m_Name: rootCrawler
|
||||
m_TagString: Untagged
|
||||
@@ -34,7 +34,24 @@ Transform:
|
||||
- {fileID: 3116162970488227892}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!96 &344069317130189608
|
||||
--- !u!114 &4811596309560135411
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1843330507631451878}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 32b713897b19bfd9fbc1d58800761b20, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: '::'
|
||||
target: {fileID: 0}
|
||||
maxHeight: 2
|
||||
crawlingSpeed: 0.5
|
||||
radius: 0.5
|
||||
rotationSpeed: 5
|
||||
--- !u!96 &8977163302937735702
|
||||
TrailRenderer:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -93,7 +110,7 @@ TrailRenderer:
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0.21667099
|
||||
value: 0.13068199
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
@@ -105,7 +122,7 @@ TrailRenderer:
|
||||
m_RotationOrder: 4
|
||||
colorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 0, g: 0, b: 0, a: 1}
|
||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
@@ -113,7 +130,7 @@ TrailRenderer:
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 6554
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
@@ -130,7 +147,7 @@ TrailRenderer:
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_ColorSpace: 0
|
||||
m_ColorSpace: -1
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
@@ -144,21 +161,6 @@ TrailRenderer:
|
||||
m_Autodestruct: 0
|
||||
m_Emitting: 1
|
||||
m_ApplyActiveColorSpace: 1
|
||||
--- !u!114 &4811596309560135411
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1843330507631451878}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 32b713897b19bfd9fbc1d58800761b20, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: '::'
|
||||
target: {fileID: 0}
|
||||
maxHeight: 3
|
||||
crawlingSpeed: 1
|
||||
--- !u!1 &8507854225114473222
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -186,7 +188,7 @@ Transform:
|
||||
m_GameObject: {fileID: 8507854225114473222}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -15.4, y: 0, z: 8.3}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -207,7 +209,7 @@ MeshRenderer:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8507854225114473222}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
|
||||
Reference in New Issue
Block a user