Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Extras;
- using UnityEngine;
- namespace Core
- {
- public class CharacterMovement : CharacterComponent
- {
- public float maxSpeed = 7;
- [HideInInspector] public float speedMultiplier = 1;
- private void Update()
- {
- if (Character.characterType != CharacterType.Player)
- return;
- var move = Vector2.zero;
- move.x = Input.GetAxis("Horizontal");
- if (move.normalized.magnitude > 0.1f)
- {
- if (move.normalized.x > 0)
- Character.FaceRight();
- else
- Character.FaceLeft();
- }
- Character.TargetVelocity = move * (maxSpeed * speedMultiplier);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement