This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
NewerOlder