mirror of
https://github.com/Team4388/2019-Virtual-Field.git
synced 2026-06-09 00:28:01 -06:00
Added some things
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class robotNavXControl : MonoBehaviour
|
||||
{
|
||||
public float distance, lastDistance;
|
||||
public Vector3 vel, acc, initRot, rot, otherRot;
|
||||
public int button;
|
||||
robotCommunication roboCom;
|
||||
bool start = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
GameObject Robot = GameObject.Find("Robot");
|
||||
roboCom = Robot.GetComponent<robotCommunication>();
|
||||
vel = new Vector3(0, 0, 0);
|
||||
rot = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
transform.position = new Vector3(0, 0, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float x = 0, y = 0, z = 0;
|
||||
roboCom.robotValues.TryGetValue("Pitch", out rot.x);
|
||||
roboCom.robotValues.TryGetValue("Yaw", out rot.y);
|
||||
roboCom.robotValues.TryGetValue("Roll", out rot.z);
|
||||
roboCom.robotValues.TryGetValue("Distance", out distance);
|
||||
rot.x *= -1;
|
||||
rot.z *= -1;
|
||||
//Angle
|
||||
//rot -= initRot;
|
||||
Vector3 finalRot = new Vector3(0, 0, 0);
|
||||
finalRot.y = rot.y - initRot.y;
|
||||
transform.rotation = Quaternion.Euler(finalRot);
|
||||
//Position
|
||||
transform.position += transform.forward * (distance - lastDistance);
|
||||
lastDistance = distance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user