You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LittleManComputer/LMC/Assets/Nigga.cs

81 lines
2.1 KiB
C#

1 year ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RobotAnimation : MonoBehaviour
{
public GameObject Robot;
public Animator robotanimation;
1 year ago
public int turning, pending, type;
public float angle, curang, lmao, speed=25f;
1 year ago
float calc(float desire)
{
lmao = desire;
if (Mathf.Abs(desire - curang) <= 180F) return desire - curang;
else return 360F - (desire - curang);
}
1 year ago
public void point1(float x, float z)
1 year ago
{
float radians = Mathf.Atan((Robot.transform.position.x - x) / (Robot.transform.position.z - z));
1 year ago
float angl = calc(radians * (180 / Mathf.PI)) / speed;
turning = (int)speed;
pending = (int)1;
1 year ago
angle = angl;
type = 0;
}
1 year ago
public void point2(float x,float z)
1 year ago
{
float radians = Mathf.Atan((Robot.transform.position.x - x) / (Robot.transform.position.z - z));
1 year ago
float angl = calc(radians * (180 / Mathf.PI)) / speed;
turning = (int)speed;
pending = (int)1;
1 year ago
angle = angl;
1 year ago
type = 1;
1 year ago
}
1 year ago
public void rest()
1 year ago
{
1 year ago
float angl = calc(0) / speed;
turning = (int)speed;
pending = (int)1;
1 year ago
angle = angl;
1 year ago
type = 2;
1 year ago
}
// Start is called before the first frame update
void Start()
{
robotanimation = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (turning > 0)
{
turning--;
Robot.transform.Rotate(0, angle, 0, Space.Self);
curang += angle;
}
if (pending > 0)
{
pending--;
if (pending == 0)
{
1 year ago
if (type == 0) robotanimation.Play("Point1");
else if (type == 1) robotanimation.Play("Point2");
else if (type == 2)
1 year ago
{
robotanimation.Play("Rest");
1 year ago
pending = 100;
type = 3;
1 year ago
}
1 year ago
else if (type == 3) robotanimation.Play("Idle");
1 year ago
}
}
}
}