using System; using Syntriax.Modules.Trigger; using UnityEngine; namespace Syntriax.Modules.Movement.Samples { public class MovementInputSample : MonoBehaviour { private IMovementController movementController = null; private Rigidbody2D rigid = null; private IGroundTrigger groundTrigger = null; private void Start() { movementController = GetComponent(); groundTrigger = GetComponentInChildren(); rigid = GetComponent(); } private Vector3 input = Vector3.zero; private void Update() { input = Vector3.zero; input.x = Input.GetAxis("Horizontal"); input.y = Input.GetAxis("Vertical"); movementController.Move(input); if (Input.GetKeyDown(KeyCode.Space) && groundTrigger.IsTrigerred) Jump(); } private void Jump() { Vector2 velocity = rigid.velocity; velocity.y = 10f; rigid.velocity = velocity; } } }