initial commit
This commit is contained in:
parent
8766216908
commit
23576e137e
1033 changed files with 499339 additions and 0 deletions
23
Assets/Scripts/Player.cs
Normal file
23
Assets/Scripts/Player.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : Entity
|
||||
{
|
||||
[Header("Ground Detection")]
|
||||
[SerializeField] private Transform groundCheck;
|
||||
[SerializeField] private LayerMask groundLayer;
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * speed, rb.linearVelocityY);
|
||||
if (Input.GetKeyDown(KeyCode.Space) && OnGround())
|
||||
{
|
||||
movement.y = jumpPower;
|
||||
}
|
||||
rb.linearVelocity = movement;
|
||||
}
|
||||
|
||||
private bool OnGround()
|
||||
{
|
||||
return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue