using UnityEngine;
using System.Collections;
public class controller : MonoBehaviour {
public GameObject player;
public GameObject spinModel;
public GameObject sonic;
public GameObject sonicModel;
public GameObject enemy;
public GameObject _camera;
private GameObject closest;
public GameObject camera;
public GameObject ringS;
public Transform ring;
public GameObject bone;
public int playerHealth = 1;
public int rings = 0;
public bool AttackIsGo = false;
public bool rotateAirEnable = true;
public bool localRotat = false;
public bool inJump = false;
public bool goDash = false;
public bool PlayerInLoopdeloop = false;
public Vector3 gravityVector = Vector3.zero;
public Vector3 moveDirection = Vector3.zero;
public Vector3 dashDirection = Vector3.zero;
public Vector3 moveDirectionT = Vector3.zero;
public Vector3 moveDirectionNOT = Vector3.zero;
public Vector3 slide = Vector3.zero;
public float inAirSpeed = 600f;
public bool isGroundeds = false;
public bool secondJump = false;
public bool leftDash = false;
public bool reightDash = false;
public float dashJumpSpeed = 3f;
public float speed = 1f;
public float speeed = 1f;
public float speedOfSpeed = 2f;
public float boost = 7f;
public float inAirDash = 5f;
public float inAirBoost = 10f;
public float jumpSpeed = 5f;
public float secondJumpSpeed = 3;
public float gravity = 8f;
public float curDistance;
public float distance;
public float maxDashDistance = 80;
public float distanceHit = 5000;
public float hommingAttackSpeed = 10f;
public float reload = 0;
public float hold = 0f;
public float miniDashSpeed = 1f;
public AnimationClip run;
public AnimationClip stay;
public AnimationClip spin;
public AnimationClip jump;
public AnimationClip boostt;
public AnimationClip fall;
public AnimationClip fly;
public AnimationClip jumpUp;
public AnimationClip jumpDown;
public AnimationClip hommingAttack;
public AnimationClip dashed;
public AnimationClip hit;
public AnimationClip getDamageAnim;
public AnimationClip deathAnim;
private float stayAnimSpeed = 0.05f;
public float speedRot = 10f;
public float airSpeedRot = 1;
public float rotatingSpeed = 500;
public float distGround;
public float deadTime = 2;
public bool dead = false;
public Quaternion fromToRotate;
public Quaternion fromToRotateNoY;
public float jumpingSpidd = 1;
public GameObject ringg = new GameObject();
public int max = 0;
public int i = 0;
public Transform prefab;
public bool dash = false;
public float boneRoatSpeed = 100f;
public float dashTime = 0;
public float holding = 1;
public float scalingSpeed = 10;
public float volume = 1;
public float maxInAirSpeed = 10;
public float invincibleTime = 1.5f;
public bool getDamageBool = false;
public bool invincible = false;
private Vector3 minScale = Vector3.zero;
private Vector3 maxScale = new Vector3(5.175858f,5.175858f,5.175858f);
public AudioClip music;
public AudioClip musicTwo;
public AudioClip boostSound;
public AudioClip longBoostSound;
public AudioClip jumpSound;
public AudioClip dashSound;
public AudioClip sonicSay;
public AudioClip springSound;
public AudioClip go;
public AudioClip whooo;
public AudioClip enemyGetDamage;
public AudioClip yeah;
public AudioClip hoap;
public AudioClip booster;
public AudioClip tramplin;
public AudioClip speedRingSound;
public AudioClip getRing;
public AudioClip lossRing;
public AudioClip getDamage;
public AudioClip death;
public Transform obj;
public GameObject[] checkPoint;
public bool teleported = false;
public GameObject closestCP;
public GameObject deathh;
public GameObject dashRing;
public bool jumped;
public bool gr;
public bool platforming = false;
public bool action;
private GameObject platform;
public bool inRoof;
public bool tramplinJump = false;
public bool cameraChange = false;
public GameObject splash;
public AudioClip splashh;
public Vector3 playerVelosity = Vector3.zero;
public bool stoped;
// Use this for initialization
void Start ()
{
audio.PlayOneShot(music);
player.gameObject.SetActiveRecursively(true);
sonicModel.animation.AddClip(run,"run");
sonicModel.animation.AddClip(stay,"stay");
sonicModel.animation.AddClip(spin,"spin");
sonicModel.animation.AddClip(jump,"jump");
sonicModel.animation.AddClip(jumpUp,"jumpUp");
sonicModel.animation.AddClip(jumpDown,"jumpDown");
sonicModel.animation.AddClip(boostt,"boost");
sonicModel.animation.AddClip(fall,"fall");
sonicModel.animation.AddClip(fly,"fly");
sonicModel.animation.AddClip(hommingAttack,"hommAttack");
sonicModel.animation.AddClip(hit,"hit");
sonicModel.animation.AddClip(dashed,"dash");
sonicModel.animation.AddClip(getDamageAnim,"getDamage");
sonicModel.animation.AddClip(deathAnim,"death");
ringS = GameObject.FindGameObjectWithTag("Ring");
enemy = GameObject.FindGameObjectWithTag("Enemy");
camera = GameObject.FindGameObjectWithTag("MainCamera");
platform = GameObject.FindGameObjectWithTag("Platform");
}
// Update is called once per frame
void Update ()
{
if(playerHealth <0)playerHealth = 0;
TrailRenderer rend = spinModel.GetComponent<TrailRenderer>();
TrailRenderer rendTwo = player.GetComponent<TrailRenderer>();
CharacterController controller = GetComponent<CharacterController>();
RaycastHit rayy;
Physics.Raycast(transform.position,-transform.up,out rayy);
distGround = transform.position.y - rayy.point.y;
if(isGroundeds == true || gr == true)
{
player.gameObject.SetActiveRecursively(true);
spinModel.gameObject.SetActiveRecursively(false);
rend.startWidth = Mathf.MoveTowards(rend.startWidth,0,80 * Time.deltaTime);
rend.endWidth = Mathf.MoveTowards(rend.endWidth,0,80 * Time.deltaTime);
}
if(isGroundeds == false || gr == true)
{
rend.startWidth = Mathf.MoveTowards(rend.startWidth,5,80 * Time.deltaTime);
rend.endWidth = Mathf.MoveTowards(rend.endWidth,1,80 * Time.deltaTime);
if(inJump == true && speed > 3)speed = 3;
}
controller.center = new Vector3(0,0,0);
//Прыжек
if(controller.isGrounded == true)
{
if(Input.GetKeyDown(KeyCode.Space))
{
gravityVector.y = jumpSpeed;
audio.PlayOneShot(jumpSound);
jumped = true;
}
}
gr = controller.isGrounded;
//Движение
if(getDamageBool == false) controller.Move(sonic.transform.forward * speed);
//Движение перпендикулярно поверхности
RaycastHit downRay;
Physics.Raycast(transform.position,-transform.up,out downRay);
Quaternion fromToRotate = Quaternion.FromToRotation(Vector3.up,downRay.normal);
Quaternion ftr = Quaternion.Euler(fromToRotate.eulerAngles.x,fromToRotate.eulerAngles.y,fromToRotate.eulerAngles.z);
if(isGroundeds == true)
{
transform.rotation = Quaternion.RotateTowards(transform.rotation,ftr,speedRot);
}
//подскакивание на трамплинах
if(tramplinJump == true)
{
if((transform.eulerAngles.z > 50 && transform.eulerAngles.z < 100) || (transform.eulerAngles.z < 350 && transform.eulerAngles.z > 250) || (transform.eulerAngles.x < 350 && transform.eulerAngles.x > 250) && (transform.eulerAngles.x > 50 && transform.eulerAngles.x < 100))
{
goDash = true;
}
if((transform.eulerAngles.x > 250 && transform.eulerAngles.x < 300) || (transform.eulerAngles.x > 50 && transform.eulerAngles.x < 100))
{
goDash = true;
}
if(isGroundeds == true && gravityVector.y < 7)goDash = false;
if(goDash == true && speed > 5)
{
goDash = false;
jumped = true;
audio.PlayOneShot(dashSound);
gravityVector = transform.InverseTransformDirection(gravityVector);
moveDirection = transform.InverseTransformDirection(moveDirection);
gravityVector.y = 5;
speed = 1f;
transform.rotation = Quaternion.Euler(0,0,0);
}
}
if(isGroundeds == false && goDash == false)moveDirection.x = 1;
//Поворот если в воздухе
if(isGroundeds == false)
{
if(rotateAirEnable == true)
{
Quaternion inAirRotate = Quaternion.Euler(0,transform.rotation.y,0);
transform.rotation = Quaternion.RotateTowards(transform.rotation,inAirRotate,airSpeedRot);
if(gravityVector.y < 0)transform.rotation = Quaternion.RotateTowards(transform.rotation,inAirRotate,airSpeedRot * 1.3f);
}
}
//Вектор к земле
RaycastHit isGrounded;
isGroundeds = Physics.Raycast(transform.position,-transform.up,out isGrounded,8f);
//Движение
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
dashTime -= Time.deltaTime;
if(dashTime <= 0)dashTime = 0;
//Рывки в воздухе
if(dash == true)
{
moveDirection.x *= inAirDash;
moveDirection.z *= inAirDash;
player.gameObject.SetActiveRecursively(true);
spinModel.gameObject.SetActiveRecursively(false);
}
if(isGroundeds == true)
{
inAirDash = 3;
dash = false;
}
//Рывки
if(Input.GetKeyUp(KeyCode.E))reightDash = true;
if(Input.GetKeyUp(KeyCode.Q))leftDash = true;
if(controller.isGrounded == true)
{
leftDash = false;
reightDash = false;
}
if(leftDash == true)
{
moveDirection.x = -miniDashSpeed;
reightDash = false;
sonicModel.animation.Play("dash");
}
if(reightDash == true)
{
moveDirection.x = miniDashSpeed;
leftDash = false;
sonicModel.animation.Play("dash");
}
//Ускорение boost
moveDirectionNOT = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
Quaternion lookrotate = Quaternion.LookRotation(moveDirectionNOT);
if(Input.GetKeyDown(KeyCode.Mouse0) && isGroundeds == true)
{
speed = boost;
audio.PlayOneShot(boostSound);
audio.PlayOneShot(whooo);
if(moveDirectionNOT.x != 0||moveDirectionNOT.z != 0)
{
sonic.transform.localRotation = Quaternion.RotateTowards(sonic.transform.localRotation,lookrotate,9999* Time.deltaTime);
}
}
//Делаю рывок в воздухе
if(isGroundeds == false)
{
if(speed > maxInAirSpeed) speed = maxInAirSpeed;
if(Input.GetKeyDown(KeyCode.Mouse0) && dash == false && distance > distanceHit)
{
dash = true;
inAirDash = 3;
if(speed > 3)speed = 3;
audio.PlayOneShot(dashSound);
audio.PlayOneShot(go);
rendTwo.startWidth = Mathf.MoveTowards(rendTwo.startWidth,5,80 * Time.deltaTime);
rendTwo.endWidth = Mathf.MoveTowards(rendTwo.endWidth,1,80 * Time.deltaTime);
}
if(dash == true)sonicModel.animation.Play("dash");
}
if(moveDirection.x != 0 || moveDirection.z != 0 || Input.GetKey(KeyCode.T))
{
speed = Mathf.MoveTowards(speed,25,speedOfSpeed * Time.deltaTime);
} else speed = Mathf.MoveTowards(speed,0,8 * Time.deltaTime);
//Проскальзывание
if((fromToRotate.z < -0.3f||fromToRotate.z > 0.3f ||fromToRotate.x < -0.3f||fromToRotate.x > 0.3f) && speed < 2)
{
if(controller.isGrounded == true)
{
slide = new Vector3(fromToRotate.z,fromToRotate.y,-fromToRotate.x);
moveDirection -= slide * 50 * Time.deltaTime;
PlayerInLoopdeloop = true;
}
}
if(speed < 5 && getDamageBool == false && dead == false)controller.Move(moveDirection);
//Применение гравитации
gravityVector.y -= gravity * Time.deltaTime;
controller.Move(new Vector3(0,gravityVector.y,0));
if(gravityVector.y <= -gravity)
{
gravityVector.y = -gravity;
}
//Если скорость больше или равно 5 гравитации нет
if(speed >= 5)
{
gravityVector = transform.TransformDirection(0,gravityVector.y,0);
if(isGroundeds == true)
{
gravity = 8;
if(Input.GetKeyDown(KeyCode.Space))
{
gravityVector.y = jumpSpeed;
audio.PlayOneShot(jumpSound);
}
}
if(moveDirection.x != 0 && moveDirection.z == 0)
{
rendTwo.startWidth = Mathf.MoveTowards(rendTwo.startWidth,5,80 * Time.deltaTime);
rendTwo.endWidth = Mathf.MoveTowards(rendTwo.endWidth,1,80 * Time.deltaTime);
}
}
else gravityVector = transform.InverseTransformDirection(0,gravityVector.y,0);
if(speed < 5 || moveDirection.z != 0)
{
rendTwo.startWidth = Mathf.MoveTowards(rendTwo.startWidth,0,80 * Time.deltaTime);
rendTwo.endWidth = Mathf.MoveTowards(rendTwo.endWidth,0,80 * Time.deltaTime);
}
if(isGroundeds == false && jumped == false)
{
gravityVector.y = 0;
jumped = true;
}
if(gravityVector.y < -1 && isGroundeds == true)jumped = false;
//Анимации=====================================================================================
if(dead == false) //Если жив
{
if(moveDirection.x != 0)
{
sonicModel.animation.CrossFade("run");
sonicModel.animation["run"].speed = speed/2f;
}
else if(moveDirection.z != 0)
{
sonicModel.animation.CrossFade("run");
sonicModel.animation["run"].speed = speed/2f;
}
else sonicModel.animation.CrossFade("stay");
sonicModel.animation["stay"].time = stayAnimSpeed;
if(speed >= 5)
{
sonicModel.animation.CrossFade("boost");
sonicModel.animation["boost"].speed = speed/4f;
}
if(isGroundeds == false)
{
if(gravityVector.y > 0)sonicModel.animation.Play("jumpUp");
if(gravityVector.y < 0)sonicModel.animation.CrossFade("jumpDown");
}
}
//Поиск ближайшего врага
GameObject[]gos;
gos = GameObject.FindGameObjectsWithTag("Enemy");
distance = Mathf.Infinity;
foreach(GameObject go in gos)
{
Vector3 diff = go.transform.position - transform.position;
curDistance = diff.sqrMagnitude;
if(curDistance < distance)
{
distance = curDistance;
closest = go;
}
if(closest == null)break;
}
//Homming Attack=====================================================================================
//Двойной прыг
if(Input.GetKeyDown(KeyCode.Space) && isGroundeds == false && AttackIsGo == false && secondJump == false)
{
secondJump = true;
gravityVector.y = secondJumpSpeed;
audio.PlayOneShot(dashSound);
audio.PlayOneShot(yeah);
spinModel.SetActiveRecursively(true);
sonicModel.SetActiveRecursively(false);
sonicModel.animation.Play("dash");
if(distance > distanceHit) audio.PlayOneShot(hoap);
if(speed > 3)speed = 3;
}
if(isGroundeds == true)secondJump = false;
if(distance < distanceHit)
{
if(Input.GetKeyDown(KeyCode.Mouse0) && controller.isGrounded == false && Time.time > reload)
{
if(distance < distanceHit) AttackIsGo = true;
reload = Time.time + hold;
Vector3 rot = closest.transform.position - transform.position;
if(controller.isGrounded == false) sonic.transform.rotation = Quaternion.LookRotation(new Vector3(rot.x,transform.rotation.y,rot.z));
audio.PlayOneShot(dashSound);
audio.PlayOneShot(sonicSay);
}
}
//если нажал удар в воздухе
if(AttackIsGo == true && Time.time > reload)
{
float step = inAirSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position,closest.transform.position,step);
spinModel.gameObject.SetActiveRecursively(true);
rend.startWidth = Mathf.MoveTowards(rend.startWidth,5,80 * Time.deltaTime);
rend.endWidth = Mathf.MoveTowards(rend.endWidth,1,80 * Time.deltaTime);
sonicModel.animation.CrossFade("dash");
speed = 1;
}
//убивание врага
if(distance < maxDashDistance + 200 && controller.isGrounded == false && action == false)
{
AttackIsGo = false;
enemyHealth healthEnemy = closest.gameObject.GetComponent<enemyHealth>();
healthEnemy.health = 0;
gravityVector.y = dashJumpSpeed;
player.gameObject.SetActiveRecursively(false);
spinModel.gameObject.SetActiveRecursively(true);
}
if(speed >= 6 && isGroundeds == true && distance < maxDashDistance + 200)
{
enemyHealth healthEnemy = closest.gameObject.GetComponent<enemyHealth>();
healthEnemy.health = 0;
}
//Получение урона
if(distance < maxDashDistance && controller.isGrounded == true && rings > 0 && invincibleTime == 0)
{
invincibleTime = 1.5f;
getDamageBool = true;
gravityVector.y = dashJumpSpeed;
getDamageBool = true;
gravityVector.y = jumpSpeed;
if(rings > 10)rings = 10;
for(i = rings;i > 0;i--)
{
Vector3 ringsDir = new Vector3(transform.position.x,transform.position.y + i,transform.position.z);
Transform ringo = Instantiate(ring,ringsDir,Quaternion.identity)as Transform;
audio.PlayOneShot(lossRing);
}
rings = 0;
audio.PlayOneShot(lossRing);
audio.PlayOneShot(getDamage);
sonicModel.animation.Play("getDamage");
}
//Смерть
if(distance < maxDashDistance && controller.isGrounded == true && rings <= 0 && dead == false)
{
audio.PlayOneShot(death);
if(invincibleTime == 0) dead = true;
teleported = false;
deadTime = 2;
getDamageBool = true;
gravityVector.y = dashJumpSpeed;
animation.Play("death");
}
//Бессмертие
if(invincibleTime <= 0)invincibleTime = 0;
if(invincibleTime > 0)invincibleTime -= Time.deltaTime;
if(invincibleTime > 0)invincible = true;
if(invincibleTime == 0)invincible = false;
//Повороты=====================================================================================
if((moveDirectionNOT.x != 0||moveDirectionNOT.z != 0) && dead == false)
{
sonic.transform.localRotation = Quaternion.RotateTowards(sonic.transform.localRotation,lookrotate,rotatingSpeed* Time.deltaTime);
}
moveDirection = moveDirection.normalized;
//Поворот на скоростях
if(speed >= 5)
{
if(isGroundeds == true)rotatingSpeed = 1500 / speed;
if(isGroundeds == false)rotatingSpeed = 500;
}
//Получение урона
if(controller.isGrounded == true && distance > maxDashDistance)getDamageBool = false;
if(getDamageBool == true)
{
controller.Move(-sonic.transform.forward * 2);
}
//Тормоза на скоростях
RaycastHit stop;
stoped = Physics.Raycast(sonic.transform.position,sonic.transform.forward,out stop,5);
if(stoped == true)
{
speed = 1;
}
Quaternion myRot = sonic.transform.rotation;
if(Input.GetKeyDown(KeyCode.Mouse1) && isGroundeds == true)
{
speed = 0;
audio.PlayOneShot(dashSound);
} else if(Input.GetKeyDown(KeyCode.Mouse1) && isGroundeds == false)
{
gravityVector.y = - 10;
audio.PlayOneShot(dashSound);
}
if(sonic.transform.rotation.y == 270 && Input.GetKey(KeyCode.A) && speed > 3)
{
speed = 0;
audio.PlayOneShot(dashSound);
}
if(sonic.transform.rotation.y > 45 && sonic.transform.rotation.y < 125 && Input.GetKey(KeyCode.D) && speed > 3)
{
speed = 0;
audio.PlayOneShot(dashSound);
}
//Смерть смерть смерть!!!
if(deadTime > 0)deadTime -= Time.deltaTime;
if(deadTime <= 0)
{
deadTime = 0;
dead = false;
}
//Перемещение на чекпойнт
checkPoint = GameObject.FindGameObjectsWithTag("CheckPoint");
float distanceCP = Mathf.Infinity;
foreach(GameObject ClosCP in checkPoint)
{
Vector3 diff = ClosCP.transform.position - transform.position;
float curDist = diff.sqrMagnitude;
if(curDist < distanceCP)
{
closestCP = ClosCP;
distanceCP = curDistance;
}
}
if(dead == true && teleported == false)
{
transform.position = closestCP.transform.position;
teleported = true;
}
//Обнуление вектора гравитации если башкой в потолок
RaycastHit headInRoof;
bool headInroof;
headInroof = Physics.Raycast(transform.position,transform.up,out headInRoof,5);
if(headInroof == true)
{
if(headInRoof.collider.gameObject.CompareTag("Platform"))headInRoof.collider.isTrigger = true;
}
//Всякие действия - дешпад,трамплин,кольцо,пружина.
RaycastHit actionHit;
action = Physics.Raycast(transform.position,-transform.up,out actionHit,5);
if(action == true)
{
//Платформы
if(actionHit.collider.gameObject.CompareTag("Platform"))
{
actionHit.collider.isTrigger = false;
}
//Ускорители
if(actionHit.collider.gameObject.CompareTag("Booster"))
{
objectScript boosterDirection = actionHit.collider.gameObject.GetComponent<objectScript>();
sonic.transform.rotation = actionHit.collider.gameObject.transform.rotation;
audio.PlayOneShot(booster);
speed = boosterDirection.bosterSpeed;
}
//Прыжки на подпрыгивалках
if(actionHit.collider.gameObject.CompareTag("SpringUp"))
{
objectScript springDirection = actionHit.collider.gameObject.GetComponent<objectScript>();
gravityVector = springDirection.direct;
audio.PlayOneShot(springSound);
}
//Трамплины
if(actionHit.collider.gameObject.CompareTag("Tramplin"))
{
objectScript tramplinDirection = actionHit.collider.gameObject.GetComponent<objectScript>();
gravityVector = tramplinDirection.direct;
speed = tramplinDirection.tramplinSpeed;
audio.PlayOneShot(booster);
sonic.transform.rotation = actionHit.collider.gameObject.transform.rotation;
sonicModel.animation.Play("dash");
}
//Кольца ускорители
if(actionHit.collider.gameObject.CompareTag("SpeedRing"))
{
objectScript ringDirection = actionHit.collider.gameObject.GetComponent<objectScript>();
sonic.transform.rotation = actionHit.collider.gameObject.transform.rotation;
speed = ringDirection.speedRing;
audio.PlayOneShot(speedRingSound);
gravityVector.y = 0;
transform.position = actionHit.transform.position;
}
//Смерть
if(actionHit.collider.gameObject.CompareTag("Death"))
{
GameObject splashed = Instantiate(splash,transform.position,Quaternion.identity) as GameObject;
Debug.Log("Splash!");
Debug.Log("dead");
audio.PlayOneShot(death);
audio.PlayOneShot(splashh);
dead = true;
teleported = false;
deadTime = 2;
animation.Play("death");
}
if(actionHit.collider.gameObject.CompareTag("Enemy"))
{
AttackIsGo = false;
enemyHealth healthEnemy = closest.gameObject.GetComponent<enemyHealth>();
healthEnemy.health = 0;
gravityVector.y = dashJumpSpeed;
player.gameObject.SetActiveRecursively(false);
spinModel.gameObject.SetActiveRecursively(true);
}
//Сбор колец
if(actionHit.collider.gameObject.CompareTag("Ring") && invincibleTime == 0)
{
rings ++;
Destroy(actionHit.collider.gameObject);
}
}
//Смена камеры
RaycastHit camChange;
cameraChange = Physics.Raycast(sonicModel.transform.position,sonicModel.transform.forward,out camChange,5);
if(isGroundeds == false)
{
if(gr == true)transform.Translate(sonic.transform.forward * 2);
}
//Толкаю если не хочет идти
playerVelosity = controller.velocity;
if(moveDirection.x != 0 && playerVelosity.x == 0)
{
}
if(moveDirection.z != 0 && playerVelosity.z == 0)
{
}
}
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.collider.gameObject.CompareTag("Enemy"))
{
if(isGroundeds == false && getDamageBool == false)
{
Debug.Log("Kill!");
enemyHealth healthEnemy = hit.collider.gameObject.GetComponent<enemyHealth>();
sonicModel.animation.Play("hit");
healthEnemy.health -= 100f;
gravityVector.y = dashJumpSpeed;
player.gameObject.SetActiveRecursively(false);
spinModel.gameObject.SetActiveRecursively(true);
TrailRenderer rend = spinModel.GetComponent<TrailRenderer>();
rend.startWidth = Mathf.MoveTowards(rend.startWidth,5,80 * Time.deltaTime);
rend.endWidth = Mathf.MoveTowards(rend.endWidth,1,80 * Time.deltaTime);
audio.PlayOneShot(enemyGetDamage);
}
//Сбор колец
if(hit.collider.gameObject.CompareTag("Ring") && invincibleTime == 0)
{
rings ++;
Destroy(hit.collider.gameObject);
}
}
}
void applyDamage()
{
}
}