Skip to content
Snippets Groups Projects
Commit 562c31ee authored by Jacky Chen's avatar Jacky Chen
Browse files

Added Player - Code

parent 1e070f82
Branches
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : Character
{
[SerializeField]
private HealthStat Health;
private readonly float maxHealth = 100;
protected override void Start()
{
Health.Initialize(maxHealth, maxHealth);
base.Start();
}
protected override void Update()
{
GetInput();
base.Update();
}
private void GetInput()
{
direction = Vector2.zero;
if (Input.GetKeyDown(KeyCode.Z))
{
Health.MyCurrentValue -= 10;
}
if (Input.GetKeyDown(KeyCode.X))
{
Health.MyCurrentValue += 10;
}
if (Input.GetKey(KeyCode.A))
{
direction += Vector2.left;
}
if (Input.GetKey(KeyCode.D))
{
direction += Vector2.right;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
direction += Vector2.left;
}
if (Input.GetKey(KeyCode.RightArrow))
{
direction += Vector2.right;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment