ПРОВЕРКА СТОИТ ЛИ ИГРОК НА ПЛАТФОРМЕ 3Д
Я новичок создаю игру в юнити мне нужно для аниматора чтобы в полёте проигрывалась другая анимация я хочу сделать это через код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class pleer : MonoBehaviour
{
public Transform KamTransform;
public Transform KamTransform2;
public Transform KamTransform3;
public Transform KamTransform4;
Vector3 offset = new Vector3(0, 2, -3);
Vector3 offset2 = new Vector3(3, 2, 0);
Vector3 offset3 = new Vector3(0, 2, 3);
Vector3 offset4 = new Vector3(-3, 2, 0);
public int q;
public int скорость;
public int силапрышка;
public int двойной;
private Rigidbody rigidbodyrigidbody;
private float sy = 4f;
public int dg;
public int q1;
public int y = 1;
public int yp;
public int ren;
public int coin;
[SerializeField] private Animator animator;
private void Awake()
{
yp = dar.у2;
ren = dar.ren1;
coin = dar.coin1;
sy = dar.скорость1;
силапрышка = dar.силапрышка1;
двойной = dar.двойной1;
скорость = dar.скорость2;
}
void Start()
{
rigidbodyrigidbody = GetComponent<Rigidbody>();
KamTransform.transform.rotation = Quaternion.Euler(30, 0, 0);
KamTransform2.transform.rotation = Quaternion.Euler(30, -90, 0);
KamTransform3.transform.rotation = Quaternion.Euler(30, 180, 0);
KamTransform4.transform.rotation = Quaternion.Euler(20, 90, 0);
animator = GetComponent<Animator>();
}
void Update()
{
Vector3 v3 = new Vector3(q, 0, q1);
rigidbodyrigidbody.velocity = v3 * sy;
if (y == 5)
{
y = 1;
}
KamTransform.position = transform.position + offset;
KamTransform2.position = transform.position + offset2;
KamTransform3.position = transform.position + offset3;
KamTransform4.position = transform.position + offset4;
bool fire = Input.GetButtonDown("Fire1");
}
public void np()
{
if (dg <= двойной)
{
GetComponent<Rigidbody>().AddForce(new Vector3(0, силапрышка, 0));
dg++;
}
}
public void d()
{
if (y == 1)
{
q = скорость;
w90();
}
else if (y == 2)
{
q1 = скорость;
w0();
}
else if (y == 3)
{
q = -скорость;
q90();
}
else if (y == 4)
{
q1 = -скорость;
w180();
}
}
public void a()
{
if (y == 1)
{
q = -скорость;
q90();
}
else if (y == 2)
{
q1 = -скорость;
w180();
}
else if (y == 3)
{
q = скорость;
w90();
}
else if (y == 4)
{
q1 = скорость;
w0();
}
}
public void w()
{
if (y == 1)
{
q1 = скорость;
w0();
}
else if (y == 2)
{
q = -скорость;
q90();
}
else if (y == 3)
{
q1 = -скорость;
w180();
}
else if (y == 4)
{
q = скорость;
w90();
}
}
public void s()
{
if (y == 1)
{
q1 = -скорость;
w180();
}
else if (y == 2)
{
q = скорость;
w90();
}
else if (y == 3)
{
q1 = скорость;
w0();
}
else if (y == 4)
{
q = -скорость;
q90();
}
}
public void o()
{
if (y == 1)
{
q = 0;
}
else if (y == 2)
{
q1 = 0;
}
else if (y == 3)
{
q = 0;
}
else if (y == 4)
{
q1 = 0;
}
}
public void o1()
{
if (y == 1)
{
q1 = 0;
}
else if (y == 2)
{
q = 0;
}
else if (y == 3)
{
q1 = 0;
}
else if (y == 4)
{
q = 0;
}
}
public void OnCollisionStay()
{
dg = 0;
this.animator.SetTrigger(name: "q12");
}
public void OnCollisionExit()
{
this.animator.SetTrigger(name: "ped");
}
public void OnCollisionEnter()
{
this.animator.SetTrigger(name: "pad");
}
public void o133()
{
if (y == 1)
{
(KamTransform.GetComponent<Camera>() as Camera).enabled = false;
}
else if (y == 2)
{
(KamTransform2.GetComponent<Camera>() as Camera).enabled = false;
}
else if (y == 3)
{
(KamTransform3.GetComponent<Camera>() as Camera).enabled = false;
}
else if (y == 4)
{
(KamTransform4.GetComponent<Camera>() as Camera).enabled = false;
y = 0;
(KamTransform.GetComponent<Camera>() as Camera).enabled = true;
(KamTransform2.GetComponent<Camera>() as Camera).enabled = true;
(KamTransform3.GetComponent<Camera>() as Camera).enabled = true;
(KamTransform4.GetComponent<Camera>() as Camera).enabled = true;
}
y++;
}
public void w90()
{
transform.rotation = Quaternion.Euler(0, 90, 0);
}
public void q90()
{
transform.rotation = Quaternion.Euler(0, -90, 0);
}
public void w0()
{
transform.rotation = Quaternion.Euler(0, 0, 0);
}
public void w180()
{
transform.rotation = Quaternion.Euler(0, 180, 0);
}
}