C
C#2y ago
Blue

❔ Movement script not working

i need help with my movement script
4 Replies
Blue
BlueOP2y 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
danilwhale2y ago
your script isn't working because you're not updating or idk try going to $unity server
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server