22 lines
479 B
C#
22 lines
479 B
C#
using System;
|
|
using Core.Extensions;
|
|
using UnityEngine;
|
|
|
|
public class Player : Entity
|
|
{
|
|
[SerializeField] private Camera cam;
|
|
private void Update()
|
|
{
|
|
attackOriginCenter.Lookat2D(cam.ScreenToWorldPoint(Input.mousePosition));
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|