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 / 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);
@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 / 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 / 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 / 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 / Mesh.cs
Last active September 23, 2020 13:58
Объединение мешов
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))] //Добавление компонентов
[RequireComponent(typeof(MeshRenderer))]
public class Mesh : MonoBehaviour
{
void Update()
{
@Musin-Mihail
Musin-Mihail / Gen.cs
Last active September 24, 2020 10:42
Генерация кубов и объединение мешей
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class GenCube : MonoBehaviour
{
public Vector3 translation;
public Vector3 eulerAngles;
@Musin-Mihail
Musin-Mihail / Search.cs
Last active September 25, 2020 15:23
Поиск и движение к ближайшему объекту
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Search : MonoBehaviour
{
public Collider btarget;
IEnumerator Start()
{
while (true)
@Musin-Mihail
Musin-Mihail / Gen.cs
Created October 1, 2020 19:27
Генерация, если приближаешь близко.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gen : MonoBehaviour
{
GameObject player;
public GameObject block;
public Vector3[] points = new Vector3[8];
void Start()
@Musin-Mihail
Musin-Mihail / Mesh.cs
Created November 12, 2020 07:05
Генерация меша куба.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GenMesh : MonoBehaviour
{
public Material material;
void Start()
{
List<Vector3> vertices = new List<Vector3>();