4 Replies
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); } }
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); } }
your script isn't working because you're not updating
or idk
try going to $unity server
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.