implementation of drecon in unity 2022 lts
forked from:
https://github.com/joanllobera/marathon-envs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
805 B
24 lines
805 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DissapearShader : MonoBehaviour
|
|
{
|
|
public Material m_Material;
|
|
public float m_HeightThresholdMax;
|
|
public float m_HeightThresholdMin;
|
|
private float m_InitalHeight;
|
|
void Awake(){
|
|
m_InitalHeight = this.transform.position.y;
|
|
Debug.Log(m_InitalHeight);
|
|
}
|
|
void Update(){
|
|
float value = Mathf.Clamp( Remap(this.transform.position.y, m_HeightThresholdMin, m_HeightThresholdMax, 1, 0), 0, 1 );
|
|
float slerpValue = Mathf.Lerp(1, 0, Mathf.SmoothStep(1, 0, value));
|
|
m_Material.SetFloat("_DissapearValue", slerpValue);
|
|
Debug.Log( slerpValue );
|
|
}
|
|
public float Remap (float value, float from1, float to1, float from2, float to2) {
|
|
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
|
}
|
|
}
|
|
|