Skip to content

Commit

Permalink
ActionFly
Browse files Browse the repository at this point in the history
  • Loading branch information
llafuente committed Jan 17, 2017
1 parent 658439d commit ac21256
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Assets/UnityPlatformer/Scripts/AI/AIPatrol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class AIPatrol: Enemy {
/// </summary>
[Comment("Do not fall on platform edge. Go back.")]
public bool doNotFall = true;
public bool resetVelocityOnTurn = false;
/// <summary>
/// Where is facing now
/// </summary>
Expand All @@ -48,7 +49,9 @@ override public void Start() {
virtual public void OnLeftWall() {
//Debug.Log("OnLeftWall");
facing = Facing.Right;
velocity = Vector3.zero;
if (resetVelocityOnTurn) {
velocity = Vector3.zero;
}
input.SetX((float) facing);
}
/// <summary>
Expand All @@ -57,7 +60,9 @@ virtual public void OnLeftWall() {
virtual public void OnRightWall() {
//Debug.Log("OnRightWall");
facing = Facing.Left;
velocity = Vector3.zero;
if (resetVelocityOnTurn) {
velocity = Vector3.zero;
}
input.SetX((float) facing);
}
/// <summary>
Expand Down
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;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class CharacterAnimator: MonoBehaviour, IUpdateEntity {
/// <summary>
/// Previous speed changed when calling PlaybackSpeed, StopPlayback or StartPlayback
/// </summary>
[HideInInspector]
public float previousSpeed;
/// <summary>
/// Start listening
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ environment:
on_finish:
- appveyor PushArtifact C:\projects\unity-platformer\autohotkey.txt
- appveyor PushArtifact C:\projects\unity-platformer\log-unit-test.txt
- appveyor PushArtifact C:\projects\unity-platformer\unit-test-results.xml
#- appveyor PushArtifact C:\projects\unity-platformer\unit-test-results.xml
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

0 comments on commit ac21256

Please sign in to comment.