I’m looking to create a simple 3D third person controller using the new input system. I’m using the below code and input actions which almost gets me what I need; left and right is working, but up and down moves up and down instead of forward and back on the Z axis.
Can anyone let me know how to get the analog stick up/down to move the Z axis instead of Y?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour, InputMaster.IPlayerActions
{
public float walkSpeed;
public CharacterController controller;
private InputMaster inputMaster;
Vector2 MoveComposite;
Vector3 MoveDirection = Vector3.zero;
private void OnEnable(){
if (inputMaster != null)
return;
inputMaster = new InputMaster();
inputMaster.Player.SetCallbacks(this);
inputMaster.Player.Enable();
}
private void OnDisable(){
inputMaster.Disable();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
controller.Move(MoveComposite * Time.deltaTime * walkSpeed);
}
public void OnMove(InputAction.CallbackContext context){
MoveComposite = context.ReadValue<Vector2>();
}
}
