I have movement mostly working just with a slight problem. I want the player to be able to turn the direction the head it facing while being able to move side to side and backwords. im using the navMeshAgent for player movement area. so i got the touch pad to move the player around however there I could not turn around. so then i started working with getting the player to turn and move the direction the player was looking but now i cant move sided to side or backwards. i can now only move the direction the player is moving..... think i need to combined the two some how.
Code
- using UnityEngine;
- using UnityEngine.AI;
- using Valve.VR;
- public class PlayerMove : MonoBehaviour
- {
- public SteamVR_Action_Vector2 touchPadAction;
- public float movementSpeed = 0.5f;
- public float turnBuffer = 5f;
- public float turnSmoothness = 0.5f;
- private NavMeshAgent playerAgent;
- private Camera Head;
- void Start ()
- {
- playerAgent = GetComponent<NavMeshAgent>();
- Head = GetComponentInChildren<Camera>();
- }
- void Update ()
- {
- TouchPadMovement();
- }
- void TouchPadMovement()
- {
- Vector2 touchpadValue = touchPadAction.GetAxis(SteamVR_Input_Sources.LeftHand);
- if (touchpadValue != Vector2.zero)
- {
- float moveX = touchpadValue.x * movementSpeed * Time.deltaTime;
- float moveY = touchpadValue.y * movementSpeed * Time.deltaTime;
- Vector3 touchPadInput = new Vector3(moveX, 0, moveY);
- touchPadInput += Head.transform.forward;
- playerAgent.Move(touchPadInput);
- }
- }
- }
its only when I add the touchPadInput += Head.transform.forward; that he play actually move where they are looking but then no side to side or back words movement.