Merge pull request #1 from dnutiu/fix-player
Rename Player to PlayerController and move rigidbody to base class
This commit is contained in:
commit
c9fab7c6e0
2 changed files with 14 additions and 6 deletions
|
@ -1,7 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace src.Base
|
namespace src.Base
|
||||||
{
|
{
|
||||||
public abstract class PlayerBase : GameplayComponent
|
public abstract class PlayerBase : GameplayComponent
|
||||||
{
|
{
|
||||||
public float movementSpeed = 4f;
|
public float movementSpeed = 4f;
|
||||||
|
|
||||||
|
/* Movement */
|
||||||
|
protected Rigidbody2D Rigidbody2d;
|
||||||
|
|
||||||
|
protected void Start()
|
||||||
|
{
|
||||||
|
Rigidbody2d = GetComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,14 +4,11 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace src.Player
|
namespace src.Player
|
||||||
{
|
{
|
||||||
public class Player : PlayerBase
|
public class PlayerController : PlayerBase
|
||||||
{
|
{
|
||||||
/* Movement */
|
|
||||||
private Rigidbody2D _rigidbody2d;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_rigidbody2d = GetComponent<Rigidbody2D>();
|
base.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
@ -37,7 +34,7 @@ namespace src.Player
|
||||||
|
|
||||||
var movementVector = new Vector2(horizontal, vertical);
|
var movementVector = new Vector2(horizontal, vertical);
|
||||||
|
|
||||||
_rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector;
|
Rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector;
|
||||||
#elif UNITY_IOS || UNITY_ANDROID
|
#elif UNITY_IOS || UNITY_ANDROID
|
||||||
// Phone movement is not supported yet.
|
// Phone movement is not supported yet.
|
||||||
#elif UNITY_PS4 || UNITY_XBOXONE
|
#elif UNITY_PS4 || UNITY_XBOXONE
|
Loading…
Reference in a new issue