diff --git a/Assets/Scripts/Mover.cs b/Assets/Scripts/Mover.cs index e403f02..f044b7b 100644 --- a/Assets/Scripts/Mover.cs +++ b/Assets/Scripts/Mover.cs @@ -8,6 +8,11 @@ public class Mover : MonoBehaviour private Transform _transform; private Vector2 _direction; private float _maxSpeed; + public float MaxSpeed + { + get { return _maxSpeed; } + set { _maxSpeed = value; } + } public Vector2 Direction { @@ -15,11 +20,11 @@ public class Mover : MonoBehaviour set { _direction = value; } } - void Start() + void Awake() { _transform = GetComponentInParent(); _character = GetComponentInParent(); - _maxSpeed = _character.MaxSpeed; + _maxSpeed = _character != null ? _character.MaxSpeed : 1; _direction = Vector2.zero; }