4 namespace Controllers.Player
6 [RequireComponent(typeof(Rigidbody2D))]
7 public class PlayerSegment : MonoBehaviour
9 internal float sensitivity;
10 internal float verticalSensitivity;
12 internal bool moveleft;
13 internal bool moveright;
15 [SerializeField] public Control left;
16 [SerializeField] public Control right;
18 [SerializeField] public Vector3 forceOrigin;
20 [SerializeField] public float height;
21 [SerializeField] public bool isRoot;
22 [SerializeField] public bool isTop;
24 public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
25 private Rigidbody2D _rigidbody;
27 private void FixedUpdate()
31 Rigidbody.AddForceAtPosition(
32 Vector2.left * (sensitivity * (isRoot ? 2f : 1f)) + Vector2.up * (verticalSensitivity * (isRoot ? -1f : 1f)),
33 transform.position + (height * forceOrigin));
37 Rigidbody.AddForceAtPosition(
38 Vector2.right * (sensitivity * (isRoot ? 2f : 1f)) + Vector2.up * (verticalSensitivity * (isRoot ? -1f : 1f)),
39 transform.position + (height * forceOrigin));
47 public KeyCode keyCode;
48 public GameObject icon;
49 public GameObject leg;
50 public GameObject arm;