Compare commits
2 Commits
main
...
ThingsThat
Author | SHA1 | Date |
---|---|---|
CDuong | 5be2668319 | 1 year ago |
Thanh | 9e86679505 | 1 year ago |
@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class LookAtCamera : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public GameObject Ok;
|
||||
void Start()
|
||||
{
|
||||
Ok.transform.LookAt(Camera.main.transform);
|
||||
Ok.transform.Rotate(0, 180, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Ok.transform.LookAt(Camera.main.transform);
|
||||
Ok.transform.Rotate(0, 180, 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da47d6c1b5b58d444859859535f480c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,80 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RobotAnimation : MonoBehaviour
|
||||
{
|
||||
public GameObject Robot;
|
||||
public Animator robotanimation;
|
||||
public int turning, pending, type;
|
||||
public float angle, curang, lmao, speed=25f;
|
||||
|
||||
float calc(float desire)
|
||||
{
|
||||
lmao = desire;
|
||||
if (Mathf.Abs(desire - curang) <= 180F) return desire - curang;
|
||||
else return 360F - (desire - curang);
|
||||
}
|
||||
|
||||
public void point1(float x, float z)
|
||||
{
|
||||
float radians = Mathf.Atan((Robot.transform.position.x - x) / (Robot.transform.position.z - z));
|
||||
float angl = calc(radians * (180 / Mathf.PI)) / speed;
|
||||
turning = (int)speed;
|
||||
pending = (int)1;
|
||||
angle = angl;
|
||||
type = 0;
|
||||
}
|
||||
|
||||
public void point2(float x,float z)
|
||||
{
|
||||
float radians = Mathf.Atan((Robot.transform.position.x - x) / (Robot.transform.position.z - z));
|
||||
float angl = calc(radians * (180 / Mathf.PI)) / speed;
|
||||
turning = (int)speed;
|
||||
pending = (int)1;
|
||||
angle = angl;
|
||||
type = 1;
|
||||
}
|
||||
|
||||
public void rest()
|
||||
{
|
||||
float angl = calc(0) / speed;
|
||||
turning = (int)speed;
|
||||
pending = (int)1;
|
||||
angle = angl;
|
||||
type = 2;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (type == 0) robotanimation.Play("Point1");
|
||||
else if (type == 1) robotanimation.Play("Point2");
|
||||
else if (type == 2)
|
||||
{
|
||||
robotanimation.Play("Rest");
|
||||
pending = 100;
|
||||
type = 3;
|
||||
}
|
||||
else if (type == 3) robotanimation.Play("Idle");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ff8ecee6a43f2c47a75cc4793a16f31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
public class Spawner_Code : MonoBehaviour
|
||||
{
|
||||
public Canvas Canva;
|
||||
public GameObject Clone;
|
||||
public TextMeshProUGUI Number;
|
||||
public float Speed = 20;
|
||||
public Vector3 StartPoint, EndPoint;
|
||||
public bool Moving = false, OffSoon = false;
|
||||
public void Start()
|
||||
{
|
||||
Speed = 20;
|
||||
Clone.transform.position = StartPoint;
|
||||
Canva.enabled = false;
|
||||
}
|
||||
public void Change(Vector3 StartInput, Vector3 EndInput, string value)
|
||||
{
|
||||
Moving = true;
|
||||
Number.SetText(value);
|
||||
Clone.transform.position = StartInput;
|
||||
StartPoint = StartInput;
|
||||
EndPoint = EndInput;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (Moving)
|
||||
{
|
||||
Canva.enabled = true;
|
||||
if (Clone.transform.position != EndPoint)
|
||||
{
|
||||
Clone.transform.position = Vector3.MoveTowards(Clone.transform.position, EndPoint, Speed * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Moving = false;
|
||||
if(OffSoon) {
|
||||
OffSoon = false;
|
||||
Canva.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b70bdf6c06a1f964299d65114cad0037
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 768 B |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 743 B |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 705 B |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 573 B |