C
C#16mo ago
루카스

❔ Movement script not working

i need help with my movement script
4 Replies
루카스
루카스16mo ago
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class InputManager : MonoBehaviour { private PlayerInput playerInput; private PlayerInput.OnFootActions onFoot; private PlayerMotor motor; // Start is called before the first frame update void Awake() { playerInput = new PlayerInput(); onFoot = playerInput.OnFoot; motor = GetComponent<PlayerMotor>(); } // Update is called once per frame void FixedUpdate() { //tell the player motor to move using the value from out movement action. motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>()); } private void OnEnable { onFoot.Enable(); }
private void OnDisable() { onFoot.Disable(); } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMotor : MonoBehaviour { private CharacterController controller; private Vector3 playerVelocity; private float speed = 5f; // Start is called before the first frame update void Start() { controller = GetComponent<CharacterController>(); } // Update is called once per frame void Update() {
} //Receive the inputs for out InputManager.cs and apply them to the Character Controller. public void ProcessMove(Vector2 input) { Vector3 moveDirection = Vector3.zero; moveDirection.x = input.x; moveDirection.y = input.y; controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime); } }
danilwhale
danilwhale16mo ago
your script isn't working because you're not updating or idk try going to $unity server
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.