Rename Player to PlayerController and move rigidbody to base class

This commit is contained in:
Denis-Cosmin Nutiu 2019-05-29 19:31:30 +03:00
parent 21de9bff1a
commit 88ce9369da
2 changed files with 14 additions and 6 deletions

View file

@ -1,7 +1,18 @@
using System;
using UnityEngine;
namespace src.Base
{
public abstract class PlayerBase : GameplayComponent
{
public float movementSpeed = 4f;
/* Movement */
protected Rigidbody2D Rigidbody2d;
protected void Start()
{
Rigidbody2d = GetComponent<Rigidbody2D>();
}
}
}

View file

@ -4,14 +4,11 @@ using UnityEngine;
namespace src.Player
{
public class Player : PlayerBase
public class PlayerController : PlayerBase
{
/* Movement */
private Rigidbody2D _rigidbody2d;
private void Start()
{
_rigidbody2d = GetComponent<Rigidbody2D>();
base.Start();
}
private void Update()
@ -37,7 +34,7 @@ namespace src.Player
var movementVector = new Vector2(horizontal, vertical);
_rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector;
Rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector;
#elif UNITY_IOS || UNITY_ANDROID
// Phone movement is not supported yet.
#elif UNITY_PS4 || UNITY_XBOXONE