holopy3/Assets/Scripts/MicroSubMover.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2020-12-10 14:25:12 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR.WSA;
public class MicroSubMover : MonoBehaviour
{
InputMaster inputs;
Vector2 move;
Vector2 rotate;
private void Awake()
{
inputs = new InputMaster();
inputs.MicroSub.Move.performed += ctx => move = ctx.ReadValue<Vector2>();
inputs.MicroSub.Move.canceled += ctx => move = Vector2.zero;
inputs.MicroSub.Rotate.performed += ctx => rotate = ctx.ReadValue<Vector2>();
inputs.MicroSub.Rotate.canceled += ctx => rotate = Vector2.zero;
}
private void OnEnable()
{
inputs.MicroSub.Enable();
}
private void OnDisable()
{
inputs.MicroSub.Disable();
}
// Update is called once per frame
void Update()
{
Vector3 m = new Vector3(move.x, 0, move.y) *20f* Time.deltaTime;
transform.Translate(m, Space.Self);
Vector2 r = new Vector2(0, rotate.x) * 100f * Time.deltaTime;
transform.Rotate(r, Space.Self);
}
}