Skip to content

Instantly share code, notes, and snippets.

View Matthew-J-Spencer's full-sized avatar

Matthew Spencer Matthew-J-Spencer

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Unity.Services.CloudSave;
using Unity.Services.CloudSave.Internal;
using UnityEngine;
public class UnityCloudSave : ICloudSave
{
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Random = System.Random;
// This source code is used for the video. It obviously requires heavy alterations to be used in a real project.
public class ExampleGrid : MonoBehaviour
{
[SerializeField] private Vector2Int _size;
[SerializeField] private Vector2 _gap;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Unity.Services.CloudSave;
using UnityEngine;
public class CloudSaveClient : ISaveClient
{
private readonly ICloudSaveDataClient _client = CloudSaveService.Instance.Data;
@Matthew-J-Spencer
Matthew-J-Spencer / PlayerAnimator.cs
Created July 6, 2022 11:30
Control unity animations using code. Video: https://youtu.be/ZwLekxsSY3Y
using System;
using UnityEngine;
using UnityEngine.Tilemaps;
using Random = UnityEngine.Random;
public class PlayerAnimator : MonoBehaviour {
[SerializeField] private float _minImpactForce = 20;
// Anim times can be gathered from the state itself, but
// for the simplicity of the video...
Netcode package:
com.unity.netcode.gameobjects
Mutiplayer helpers (ClientNetworkTransform):
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main
ParrelSync:
https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync
using UnityEngine;
public static class Bootstrapper {
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void Execute() {
Object.DontDestroyOnLoad(Object.Instantiate(Resources.Load("Systems")));
}
}
using UnityEngine;
public class GunSprint : MonoBehaviour {
[SerializeField] private Bullet _bulletPrefab;
[SerializeField] private Transform _spawnPoint;
[SerializeField] private ParticleSystem _smokeSystem;
[SerializeField] private LayerMask _targetLayer;
[SerializeField] private float _bulletSpeed = 12;
[SerializeField] private float _torque = 120;
public class SlerpySlerp : MonoBehaviour {
[SerializeField] private Transform _start, _center, _end;
[SerializeField] private int _count = 15;
private void OnDrawGizmos() {
foreach (var point in EvaluateSlerpPoints(_start.position, _end.position, _center.position,_count)) {
Gizmos.DrawSphere(point, 0.1f);
}
Gizmos.color = Color.red;
Gizmos.DrawSphere(_center.position, 0.2f);
public class PlayerController : MonoBehaviour {
[SerializeField] private Rigidbody _rb;
[SerializeField] private float _speed = 5;
[SerializeField] private float _turnSpeed = 360;
private Vector3 _input;
private void Update() {
GatherInput();
Look();
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tile : MonoBehaviour {
[SerializeField] private Color _baseColor, _offsetColor;
[SerializeField] private SpriteRenderer _renderer;
[SerializeField] private GameObject _highlight;
public void Init(bool isOffset) {