Player
If InputsPlayer is not your main player class.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MyProject {
public class Player : MonoBehaviour {
public InputsPlayer InputsPlayer = new InputsPlayer();
void Start() {
// if player loses his controller, remove the gameObject
InputsPlayer.OnControllerChange += () => {
if (InputsPlayer.Controller == null) {
Destroy(gameObject);
}
};
// visibility
GameObject.CreatePrimitive(PrimitiveType.Cube).transform.SetParent(transform);
}
void Update() {
transform.position += (Vector3)(InputsPlayer.Move*0.1f);
}
}
}