lighting in unity code example
Example 1: unity 3d lighting
Useful links on Unity 3D lighting:
Video:
Unity (Build lightmaps) - https://www.youtube.com/watch?v=KJ4fl-KBDR8
Brackeys (Light Probes) - https://www.youtube.com/watch?v=_E0JXOZDTKA
Brackeys (Lighting basics) - https://www.youtube.com/watch?v=VnG2gOKV9dw
Sykoo (Lighting basics) - https://www.youtube.com/watch?v=oEgwFl0FN8Q
Birdmask Studio (Lightmapping) - https://www.youtube.com/watch?v=NkAJNeHqmc4
UGuruz (Lightmapping basics) - https://www.youtube.com/watch?v=okYhs6kQ0xw&t
Documentation:
Unity (Light Mode: baked) - https://docs.unity3d.com/Manual/LightMode-Baked.html
Unity (Lightmapping: Getting started) - https://docs.unity3d.com/Manual/Lightmapping.html
Unity (Lightmapping) - https://docs.unity3d.com/Manual/Lightmappers.html
Unity (Light Probes) - https://docs.unity3d.com/Manual/LightProbes.html
Introduction to Lighting and Rendering - https://learn.unity.com/tutorial/introduction-to-lighting-and-rendering
Baked Light, Light Maps and Probes - https://catlikecoding.com/unity/tutorials/custom-srp/baked-light/
Art of Lighting Game Environments - https://cgcookie.com/articles/art-of-lighting-game-environments
:) https://www.youtube.com/watch?v=dQw4w9WgXcQ
Example 2: how to crouch in unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController rb;
void Start() {
rb = GetComponent<Rigidbody>();
}
void Update() {
if(Input.GetKey(KeyCode.C)) {
controller.height = 1f;
isCrouching = true;
speed = crouchWalk;
}
else
{
controller.height = 2f;
isCrouching = false;
speed = walkSpeed;
}
}
}
Example 3: slomotion in unity 3d
using UnityEngine;
using System.Collections;
public class SlowMotion : MonoBehaviour {
float currentAmount = 0f;
float maxAmount = 5f;
void Start () {
}
void Update () {
if(Input.GetKeyDown ("insert any key here")){
if(Time.timeScale == 1.0f)
Time.timeScale = 0.3f;
else
Time.timeScale = 1.0f;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}
if(Time.timeScale == 0.03f){
currentAmount += Time.deltaTime;
}
if(currentAmount > maxAmount){
currentAmount = 0f;
Time.timeScale = 1.0f;
}
}
}