Skip to content

Instantly share code, notes, and snippets.

View Musin-Mihail's full-sized avatar

Мусин Михаил Musin-Mihail

View GitHub Profile
@Musin-Mihail
Musin-Mihail / 1.cs
Last active September 21, 2020 17:11
Изменение поля с текстом UI
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // Добавляем класс с элементами UI
public class body : MonoBehaviour
{
int loot = 0;
public Text text; // Добавляем поле с текстом
void Update()
@Musin-Mihail
Musin-Mihail / 1.cs
Last active September 21, 2020 08:49
Притягивание объектов по тегу
IEnumerator Start()
{
while(true)//Бесконечный цикл
{
Collider[] hitColliders = Physics.OverlapSphere(transform.position, 10); //Создаём массив и добавляем туда все объекты в радиусе 10
for(int i = 0; i<hitColliders.Length; i++) //Проверяем все объекты в массиве
{
if(hitColliders[i].gameObject.tag == "loot")//Если у объекта есть данный тег
{
var rb = hitColliders[i].GetComponent<Rigidbody>();// Создаём переменную rb и пемещаем туда Rigidbody
@Musin-Mihail
Musin-Mihail / player.cs
Last active September 21, 2020 08:20
Управление персонажем.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player2 : MonoBehaviour
{
public int speed = 5;
public float rotationSpeed = 100.0F;
public Rigidbody rb;
public GameObject body;
@Musin-Mihail
Musin-Mihail / ShowFPS.cs
Last active September 21, 2020 08:21
Показывает FPS, без интерфейса.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShowFPS : MonoBehaviour {
public static float fps;
void OnGUI()
{
@Musin-Mihail
Musin-Mihail / LootGravity.cs
Last active September 21, 2020 08:20
Включение гравитации, если рядом нет земля
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LootGravity : MonoBehaviour
{
void Update()
{
var number=0;
Collider[] hitColliders = Physics.OverlapSphere(transform.position, transform.lossyScale.y*0.5f);