Skip to content

Commit

Permalink
Merge pull request #40 from gud-koodi/smallFixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
Ukonhattu authored Feb 5, 2020
2 parents d24acdd + f686616 commit 72b7474
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 42 deletions.
50 changes: 25 additions & 25 deletions Assets/Resources/Prefabs/Floor1.prefab

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

2 changes: 0 additions & 2 deletions Assets/Scripts/NetworkInstantiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ internal GameObject InstantiatePlayer(Player player, bool masterObject = false)
PlayerController pc = go.GetComponent<PlayerController>();
pc.playerRigidbody = go.GetComponent<Rigidbody>();
pc.weapon = go.GetComponentInChildren<Weapon>();
pc.hitSpeed = 1.5f;
pc.speed = 10f;

NetworkMaster master = go.AddComponent<NetworkMaster>();
master.UpdateEvent = NetworkUpdate;
Expand Down
25 changes: 13 additions & 12 deletions Assets/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public class PlayerController : MonoBehaviour
{
// Start is called before the first frame update
public Rigidbody playerRigidbody;
public float speed;
public float hitSpeed;
public float speed = 15f;
public float hitSpeed = 3f;
public Weapon weapon;
private Animator animator;
private bool isAttacking;
Expand All @@ -21,26 +21,27 @@ void Start()
}

// Update is called once per frame
void Update()
void FixedUpdate()
{
ApplyMovement();
ApplyRotation();
if (!isAttacking)
{
ApplyRotation();
}

HandleWeaponAttack();
}

private void ApplyMovement()
{
float mH = Input.GetAxis("Horizontal");
float mV = Input.GetAxis("Vertical");
if (playerRigidbody.velocity.y < -10 || isAttacking)
if (playerRigidbody.velocity.y >= -10)
{
playerRigidbody.velocity = new Vector3(0, playerRigidbody.velocity.y, 0);
Vector3 movement = isAttacking ? Vector3.zero : speed * new Vector3(mH, 0, mV).normalized;
playerRigidbody.velocity = movement + (Vector3.up * playerRigidbody.velocity.y);
}
else
{
playerRigidbody.velocity = new Vector3(mH * speed, playerRigidbody.velocity.y, mV * speed);
}


if (System.Math.Abs(mH) > 0 || System.Math.Abs(mV) > 0)
{
animator.SetBool("isWalking", true);
Expand Down Expand Up @@ -78,7 +79,7 @@ private void HandleWeaponAttack()
weapon.Attack();
animator.SetBool("isAttacking", true);
isAttacking = true;
StartCoroutine(WaitAttack());
StartCoroutine(WaitAttack());
}
}

Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/DynamicsManager.asset

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

2 changes: 1 addition & 1 deletion ProjectSettings/TimeManager.asset

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

0 comments on commit 72b7474

Please sign in to comment.