As you can see by the title i have a little problem.
So this is the car script and at the dots there should be a reference.
public class Drive : MonoBehaviour
{
[SerializeField] PlayerInCar playerInCar;
[SerializeField] GameObject myTextObject;
// [SerializeField] .... continuousMove;
private TextMesh myTextMesh;
[SerializeField] Transform driverPos;
[SerializeField] bool carInUse;
[SerializeField] Collider carCollider;
[SerializeField] Vector3 moveInPosition;
[SerializeField] Transform rotation;
private List<InputDevice> leftHands;
void Start()
{
Debug.Log(playerInCar.HelloWorld());
//var ContinuousMove = this.GetComponent <ActionBasedContinuousMoveProvider> ();
//Debug.Log(ContinuousMove);
myTextMesh = myTextObject.GetComponent<TextMesh>();
}
void Update()
{
if (carInUse == false)
{
//disable ContinuousMove
//ContinuousMove.SetActive(false);
}
else
{
//enable ContinuousMove
//ContinuousMove.SetActive(true);
}
}
private void OnCollisionEnter(Collision collision)
{
GameObject hitObject = collision.gameObject;
//als speler auto raakt gaat hij erin
Debug.Log("Object Hit:" + hitObject.name);
if(hitObject.name=="Player")
{
Debug.Log("Yes, I am the player");
carInUse = true;
}
}
private void GetHands()
{
InputDevices.GetDevicesAtXRNode(XRNode.LeftHand, leftHands);
}
private void Locomotion()
{
if (leftHands.Count == 0)
return;
if (!leftHands[0].isValid)
return;
Vector2 movementVector;
if (leftHands[0].TryGetFeatureValue(CommonUsages.primary2DAxis, out movementVector))
{
// Shows that value is always zero
myTextMesh.text = ($"Left Joystick Values: {movementVector}");
if (Mathf.Abs(movementVector.x) >= 0.2f || Mathf.Abs(movementVector.y) >= 0.2f)
{
//(movementVector);
}
}
}
}
I think the problem is on the other script thats right here.
namespace UnityEngine.XR.Interaction.Toolkit
{
/// <summary>
/// Locomotion provider that allows the user to smoothly move their rig continuously over time
/// using a specified input action.
/// </summary>
/// <seealso cref="LocomotionProvider"/>
[AddComponentMenu("XR/Locomotion/Continuous Move Provider (Action-based)", 11)]
[HelpURL(XRHelpURLConstants.k_ActionBasedContinuousMoveProvider)]
public class ActionBasedContinuousMoveProvider : ContinuousMoveProviderBase
{
[SerializeField]
[Tooltip("The Input System Action that will be used to read Move data from the left hand controller. Must be a Value Vector2 Control.")]
InputActionProperty m_LeftHandMoveAction;
/// <summary>
/// The Input System Action that Unity uses to read Move data from the left hand controller. Must be a <see cref="InputActionType.Value"/> <see cref="Vector2Control"/> Control.
/// </summary>
public InputActionProperty leftHandMoveAction
{
get => m_LeftHandMoveAction;
set => SetInputActionProperty(ref m_LeftHandMoveAction, value);
}
[SerializeField]
[Tooltip("The Input System Action that will be used to read Move data from the right hand controller. Must be a Value Vector2 Control.")]
InputActionProperty m_RightHandMoveAction;
/// <summary>
/// The Input System Action that Unity uses to read Move data from the right hand controller. Must be a <see cref="InputActionType.Value"/> <see cref="Vector2Control"/> Control.
/// </summary>
public InputActionProperty rightHandMoveAction
{
get => m_RightHandMoveAction;
set => SetInputActionProperty(ref m_RightHandMoveAction, value);
}
/// <summary>
/// See <see cref="MonoBehaviour"/>.
/// </summary>
protected void OnEnable()
{
m_LeftHandMoveAction.EnableDirectAction();
m_RightHandMoveAction.EnableDirectAction();
}
/// <summary>
/// See <see cref="MonoBehaviour"/>.
/// </summary>
protected void OnDisable()
{
m_LeftHandMoveAction.DisableDirectAction();
m_RightHandMoveAction.DisableDirectAction();
}
/// <inheritdoc />
protected override Vector2 ReadInput()
{
var leftHandValue = m_LeftHandMoveAction.action?.ReadValue<Vector2>() ?? Vector2.zero;
var rightHandValue = m_RightHandMoveAction.action?.ReadValue<Vector2>() ?? Vector2.zero;
return leftHandValue + rightHandValue;
}
void SetInputActionProperty(ref InputActionProperty property, InputActionProperty value)
{
if (Application.isPlaying)
property.DisableDirectAction();
property = value;
if (Application.isPlaying && isActiveAndEnabled)
property.EnableDirectAction();
}
}
}
maybe because it has namespace?