Merge pull request #1 from dnutiu/fix-player

Rename Player to PlayerController and move rigidbody to base class
This commit is contained in:
Denis-Cosmin Nutiu 2019-05-29 19:40:18 +03:00 committed by GitHub
commit c9fab7c6e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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