Skip to content

Commit

Permalink
#601 big clouds disappear when hit something unmovable
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldgenerator7 committed Aug 7, 2024
1 parent ab003ba commit d921199
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Assets/Scripts/Mechanics/CloudMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rigidbody2D>())
{
//stop it
rb2d.velocity = Vector2.zero;
this.enabled = false;
//make it disappear
Fader fader = GetComponent<Fader>();
fader.enabled = true;
}
}
}
22 changes: 21 additions & 1 deletion Assets/Terrain/SpriteShape/Clouds/Cloud Terrain Template.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d921199

Please sign in to comment.