Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- [RequireComponent(typeof(Rigidbody2D))]
- public class JumperMover : MonoBehaviour
- {
- [SerializeField] private float _horizontalSpeedMove = 500f;
- private Rigidbody2D _rigidbody2D;
- private float _horizontalInput;
- private void Awake()
- {
- _rigidbody2D = GetComponent<Rigidbody2D>();
- }
- private void Update()
- {
- _horizontalInput = Input.GetAxis("Horizontal");
- }
- private void FixedUpdate()
- {
- _rigidbody2D.velocity = new Vector2(_horizontalInput * _horizontalSpeedMove * Time.fixedDeltaTime, _rigidbody2D.velocity.y);
- }
- }
Add Comment
Please, Sign In to add comment