Skip to content

Instantly share code, notes, and snippets.

@didacus
didacus / DamagePlayer.cs
Created November 14, 2021 15:28
Unity - Basic player damage
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamagePlayer : MonoBehaviour
{
public int damageToGive;
public void OnTriggerEnter(Collider other)
{
@didacus
didacus / GunController.cs
Created November 14, 2021 15:23
Unity - Basic gun controller
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GunController : MonoBehaviour
{
public bool isFiring;
public BulletController bullet;
public float bulletSpeed;
public float fireRate;
@didacus
didacus / EnemyHealthManager.cs
Created November 14, 2021 15:12
Unity - Basic enemy health manager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealthManager : MonoBehaviour
{
public int startingHealth;
private int currentHealth;
public float flashLength;
private float flashCounter;
@didacus
didacus / EnemyController.cs
Created November 14, 2021 15:11
Unity - Enemy controller that follows player.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController : MonoBehaviour
{
private Rigidbody RB;
public float moveSpeed;
public PlayerController thePlayer;
@didacus
didacus / BulletController.cs
Created November 14, 2021 15:05
Unity - Basic bullet controller against enemies
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletController : MonoBehaviour
{
public float speed;
public float lifeTime;
public int damageToGive;
@didacus
didacus / PlayerHealthManager.cs
Created November 14, 2021 14:28
Unity - Basic script to manage player health
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerHealthManager : MonoBehaviour
{
public int startingHealth;
private int currentHealth;
public float flashLength;
private float flashCounter;
@didacus
didacus / Character.Controller.cs
Created November 14, 2021 09:40
Unity - Controller for character movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example : MonoBehaviour
{
private CharacterController controller;
private Vector3 playerVelocity;
private bool groundedPlayer;
private float playerSpeed = 2.0f;
@didacus
didacus / CameraController.cs
Created November 14, 2021 09:30
Unity - Camera controller to follow player
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player; //Public variable to store a reference to the player game object
private Vector3 offset; //Private variable to store the offset distance between the player and camera
@didacus
didacus / SpawnableManager.cs
Created November 8, 2021 14:35
SpawnableManager AR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class SpawnableManager : MonoBehaviour
{
[SerializeField]
@didacus
didacus / launch.json
Created February 27, 2021 12:09
Chrome debug VSCODE
{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src"
}