Skip to content

Commit

Permalink
#608 add middle offset
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldgenerator7 committed Sep 10, 2024
1 parent 4296c28 commit 005af09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Assets/Enemies/Cactus/cactus_blossom.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6541020760080976190}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: 0.5614486, w: -0.82751167}
m_LocalRotation: {x: 0, y: 0, z: -0.5614481, w: 0.827512}
m_LocalPosition: {x: 281.27, y: 45.52, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
Expand All @@ -52,8 +52,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: cb12e01cb26133c47b8d2dc6f310e5fd, type: 3}
m_Name:
m_EditorClassIdentifier:
openLeft: 0
openRight: -180
openLeft: -30
openRight: -150
middleOffset: -7
_openPercent: 0
petals:
- {fileID: 6176236681032185507}
- {fileID: 5203930985161901460}
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/EnemyAI/CactusBlossomController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class CactusBlossomController : MonoBehaviour
public float openLeft = 0;
[Tooltip("How far to the right to open to. 0 is pointing to its left")]
public float openRight = 180;
[Tooltip("How much to nudge the middle petals by")]
public float middleOffset = 0;
[Range(0f, 1f)]
public float _openPercent = 1f;

Expand Down Expand Up @@ -39,7 +41,8 @@ public void placePetals(float openPercent)
{
Transform petal = petals[i];
float percent = (float)i / (float)(petals.Count - 1);
float angle = diff * percent + left;
float offset = (i > 0 && i < petals.Count - 1) ? middleOffset * openPercent : 0;
float angle = diff * percent + left + offset;
petal.localEulerAngles = new Vector3(0,0,angle);
}
}
Expand Down

0 comments on commit 005af09

Please sign in to comment.