diff --git a/Assets/Scripts/Mechanics/CloudMover.cs b/Assets/Scripts/Mechanics/CloudMover.cs index 77f4f8bc5..c15a61383 100644 --- a/Assets/Scripts/Mechanics/CloudMover.cs +++ b/Assets/Scripts/Mechanics/CloudMover.cs @@ -27,4 +27,19 @@ void FixedUpdate() rb2d.velocity = sideVector.normalized * speed; transform.up = -gravityVector; } + + private void OnCollisionEnter2D(Collision2D collision) + { + //if it collides with a solid piece of terrain, + Collider2D collider = collision.collider; + if (collider.isSolid() && !collision.collider.GetComponent()) + { + //stop it + rb2d.velocity = Vector2.zero; + this.enabled = false; + //make it disappear + Fader fader = GetComponent(); + fader.enabled = true; + } + } } diff --git a/Assets/Terrain/SpriteShape/Clouds/Cloud Terrain Template.prefab b/Assets/Terrain/SpriteShape/Clouds/Cloud Terrain Template.prefab index 8df90b2fc..693dc9536 100644 --- a/Assets/Terrain/SpriteShape/Clouds/Cloud Terrain Template.prefab +++ b/Assets/Terrain/SpriteShape/Clouds/Cloud Terrain Template.prefab @@ -16,6 +16,7 @@ GameObject: - component: {fileID: 5527956641338764716} - component: {fileID: 2761856487625864048} - component: {fileID: 3252409094762772300} + - component: {fileID: 8183533687579090971} m_Layer: 0 m_Name: Cloud Terrain Template m_TagString: Untagged @@ -278,7 +279,7 @@ Rigidbody2D: m_GameObject: {fileID: 2891230181969961447} m_BodyType: 1 m_Simulated: 1 - m_UseFullKinematicContacts: 0 + m_UseFullKinematicContacts: 1 m_UseAutoMass: 0 m_Mass: 1 m_LinearDrag: 0 @@ -345,6 +346,25 @@ MonoBehaviour: m_EditorAssetChanged: 0 spawnStateId: 0 destroyStateId: 2147483647 +--- !u!114 &8183533687579090971 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2891230181969961447} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6f6798147e3934845b4aff3e0b69fa42, type: 3} + m_Name: + m_EditorClassIdentifier: + startfade: 1 + endfade: 0 + duration: 5 + delayTime: 1 + destroyColliders: 0 + finishAction: 0 + ignorePause: 0 --- !u!1 &4461704052682818956 GameObject: m_ObjectHideFlags: 0