Skip to content

Instantly share code, notes, and snippets.

View Yecats's full-sized avatar

Stacey Haffner Yecats

View GitHub Profile
@Yecats
Yecats / UniversalPipelineTemplateShader.shader
Created May 30, 2020 02:45 — forked from phi-lira/UniversalPipelineTemplateShader.shader
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
private void LateUpdate()
{
//constantly updates the position of the camera based on the move and rotation targets
CameraRig.transform.position = Vector3.Lerp(CameraRig.transform.position, _moveTarget, Time.deltaTime * _internalMoveSpeed);
CameraRig.transform.rotation = Quaternion.Slerp(CameraRig.transform.rotation, _rotationTarget, Time.deltaTime * _internalRotationSpeed);
}
[Header("Player Settings")]
public float RotationSpeed;
private float _internalRotationSpeed = 4;
private Quaternion _rotationTarget;
/// <summary>
/// Sets the rotation target quaternion if the right mouse button is pushed when the player is moving the mouse
/// </summary>
/// <param name="context"></param>
//Rotation variables
private bool _rightMouseDown = false;
/// <summary>
/// Sets whether the player has the right mouse button down
/// </summary>
/// <param name="context"></param>
public void OnRightMouseButtonPushed(InputAction.CallbackContext context)
{
_rightMouseDown = context.ReadValue<float>() == 1;
//Zoom variables
private float _internalZoomSpeed = 4;
private Vector2 _mouseDelta;
private float _mouseScrollDelta;
/// <summary>
/// Sets the logic for zooming in and out of the level. Clamped to a min and max value to prevent zooming too far in/out.
/// </summary>
public void OnZoom(InputAction.CallbackContext context)
{
@Yecats
Yecats / CameraController.cs
Last active October 16, 2019 03:35
Part 3
public void OnMove(InputAction.CallbackContext context)
{
//Read the input value
Vector2 value = context.ReadValue<Vector2>();
//Store the value as a Vector3, making sure to move the Y input on the Z axis.
_moveDirection = new Vector3(value.x, 0, value.y);
}
private void FixedUpdate()
@Yecats
Yecats / CameraController.cs
Last active October 16, 2019 03:34
Part 2
public class CameraController : MonoBehaviour
{
//Movement variables
private float _internalMoveTargetSpeed = 8;
private float _internalMoveSpeed = 4;
private Vector3 _moveDirection;
/// <summary>
/// Sets the target direction of movement for the camera based on the input provided by the player
/// </summary>
public class CameraController : MonoBehaviour
{
[Header("General Properties")]
public GameObject CameraRig;
private Camera _actualCamera;
//Movement variables
private Vector3 _moveTarget;
// Start is called before the first frame update
void Update()
{
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100f, _layerMask))
{
Debug.Log(hit.transform.gameObject.layer);
public class GeneralInteraction : MonoBehaviour
{
private Transform _objectToLookAt = null;
private bool _isRotating = false;
private Quaternion _defaultRotation;
public void Start()
{
//Store the default rotation of the NPC in case it is rotated towards the player object later.
_defaultRotation = transform.rotation;