aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/Player/PlayerSegment.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Controllers/Player/PlayerSegment.cs')
-rw-r--r--Assets/Scripts/Controllers/Player/PlayerSegment.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/Assets/Scripts/Controllers/Player/PlayerSegment.cs b/Assets/Scripts/Controllers/Player/PlayerSegment.cs
index b713442..4d0fb4f 100644
--- a/Assets/Scripts/Controllers/Player/PlayerSegment.cs
+++ b/Assets/Scripts/Controllers/Player/PlayerSegment.cs
@@ -6,15 +6,39 @@ namespace Controllers.Player
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerSegment : MonoBehaviour
{
+ internal float sensitivity;
+ internal float verticalSensitivity;
+
+ internal bool moveleft;
+ internal bool moveright;
+
[SerializeField] public Control left;
[SerializeField] public Control right;
[SerializeField] public Vector3 forceOrigin;
[SerializeField] public float height;
+ [SerializeField] public bool isRoot;
+ [SerializeField] public bool isTop;
public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
private Rigidbody2D _rigidbody;
+
+ private void FixedUpdate()
+ {
+ if (moveleft)
+ {
+ Rigidbody.AddForceAtPosition(
+ Vector2.left * (sensitivity * (isRoot ? 2f : 1f)) + Vector2.up * (verticalSensitivity * (isRoot ? -1f : 1f)),
+ transform.position + (height * forceOrigin));
+ }
+ if (moveright)
+ {
+ Rigidbody.AddForceAtPosition(
+ Vector2.right * (sensitivity * (isRoot ? 2f : 1f)) + Vector2.up * (verticalSensitivity * (isRoot ? -1f : 1f)),
+ transform.position + (height * forceOrigin));
+ }
+ }
}
[Serializable]