I currently have a setup where the player can move forward, left, right and backwards with WASD. Basic stuff.
public class Player : MonoBehaviour
{
public InputMaster controls;
private float playerSpeed = 4f;
{
controls = new InputMaster();
controls.PlayerN.Movement.performed += ctx => Movement(ctx.ReadValue<Vector2>());
controls.PlayerN.Movement.performed += ctx => move = ctx.ReadValue<Vector2>();
controls.PlayerN.Movement.canceled += ctx => move = Vector2.zero;
}
void Update()
{
Vector2 inputVector = controls.PlayerN.Movement.ReadValue<Vector2>();
inputVector = new Vector2(move.x, move.y) * Time.deltaTime * playerSpeed;
Vector3 finalVector = new Vector3();
finalVector.x = inputVector.x;
finalVector.z = inputVector.y;
transform.Translate(finalVector, Space.World);
private void OnEnable()
{
controls.Enable();
}
private void OnDisable()
{
controls.Disable();
}
}
}
above is how I've been calling the movement. You might notice that the actionmap is called PlayerN, that's because I have 4 action maps in total, and the idea is that I want the player to switch to the next one when the camera rotates 90 degrees around the player(North, East, South, West). For example, my action map called `PlayerE' has movement left on W, movement right on S, movement down on A and movement up on D. I just reoriented the WASD keys.
I'm currently at a loss for how switch over to a different actionmap. I've looked at the documentation for the new input system and I can't find any good info for this.
I had an idea for how to fix this but I don't know if I'm on the right track or not. I have a switch loop which checks an int in another script called camDirection, and I have this part located in my void Update() function.
switch (refScript.camDirection)
{
case -3:
Debug.Log("Facing East");
break;
case -2:
Debug.Log("Facing South");
break;
case -1:
Debug.Log("Facing West");
break;
case 0:
Debug.Log("Facing North");
break;
case 1:
Debug.Log("Facing East");
break;
case 2:
Debug.Log("Facing South");
break;
case 3:
Debug.Log("Facing West");
break;
}
Anyways, I'm currently stuck with this so if anyone has any ideas how to fix this I'd really appreciate it.