forked from llafuente/unity-platformer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Assets/UnityPlatformer/Scripts/Characters/Actions/CharacterActionFly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace UnityPlatformer { | ||
/// <summary> | ||
/// This is a Hacky Action to keep the Character from falling.\n | ||
/// The reason is that you cannot set 0,0 as gravity in the character, because | ||
/// it means use global configuration | ||
/// </summary> | ||
public class CharacterActionFly: CharacterAction { | ||
public override void OnEnable() { | ||
base.OnEnable(); | ||
} | ||
/// <summary> | ||
/// Oppose gravity, do not fall | ||
/// </summary> | ||
public override void PerformAction(float delta) { | ||
character.velocity.y -= pc2d.gravity.y * delta; | ||
} | ||
/// <summary> | ||
/// Always. | ||
/// </summary> | ||
public override int WantsToUpdate(float delta) { | ||
return -1; | ||
} | ||
|
||
public override PostUpdateActions GetPostUpdateActions() { | ||
return PostUpdateActions.WORLD_COLLISIONS | PostUpdateActions.APPLY_GRAVITY; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/UnityPlatformer/Scripts/Characters/Actions/CharacterActionFly.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters