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.
46 lines
1.2 KiB
46 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cinemachine;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
public class ActuationsSine : MonoBehaviour
|
|
{
|
|
private Material m_ActuationsMaterial;
|
|
public SkinnedMeshRenderer m_Material;
|
|
public CinemachineVirtualCamera m_Camera;
|
|
|
|
public float m_CameraFOVMin;
|
|
public float m_CameraFOVMax;
|
|
|
|
private float m_Sin = 0f;
|
|
|
|
public float m_SinValue = 0.1f;
|
|
|
|
private void Start(){
|
|
m_ActuationsMaterial = m_Material.GetComponent<SkinnedMeshRenderer>().sharedMaterial;
|
|
Debug.Log(m_ActuationsMaterial.name);
|
|
}
|
|
|
|
private void Update(){
|
|
m_Sin += m_SinValue;
|
|
float sin = Mathf.Sin(m_Sin);
|
|
|
|
float mappedFOV = Map(m_CameraFOVMin, m_CameraFOVMax, -1, 1, sin);
|
|
m_Camera.m_Lens.FieldOfView = mappedFOV;
|
|
|
|
|
|
float mappedVertex = Map(50f, 20f, -1, 1, sin);
|
|
m_ActuationsMaterial.SetFloat("Vector1_B2CC132F", mappedVertex);
|
|
}
|
|
|
|
public float Map(float from, float to, float from2, float to2, float value){
|
|
if(value <= from2){
|
|
return from;
|
|
}else if(value >= to2){
|
|
return to;
|
|
}else{
|
|
return (to - from) * ((value - from2) / (to2 - from2)) + from;
|
|
}
|
|
}
|
|
}
|
|
|