#material value doesn't change at runtime
1 messages · Page 1 of 1 (latest)
this is whole code
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class materialIntensityChanger : MonoBehaviour
{
[SerializeField] float speed;
[SerializeField] float range;
[SerializeField] Material material;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
material.SetFloat("_EmissiveIntensity", Mathf.PingPong(Time.time * speed, range));
}
}
this is problem
it is changing in game, only if i click and drag the value
material value doesn't change at runtime
Probably because the value changes so drastically when you drag. Try setting the starting value to 0 and increasing the speed to 100 or something.
actually the starting value is 0 at mathf.pingpong
also the value is changing everytime when i don't touch, you see
From what I've seen in the video it starts from ~5 and goes up slowly.
no it comes up to "24" (EV100) value that wanted. i made the speed 5000 as you see in last of video
i don't think it's about codes or something like that simple, it's probably about shaders or some systemical thing
You changed the speed but it doesn't seem to affect anything. It still increases super slow. Not to mention that it should jump between 2 ranges instead of increasing indefinitely.
But yeah, it does look weird.
What I'd try to do first is get an active camera enabled in the scene, because it looks like you don't have one.
As well as address the errors in the console.
hi guys i found an alternative idea
this doesn't change the "intensity" but it can change the brightness.
if you enabled the emission and entered your emission valu true, then enable the "emission multiply"
it multiplies the emission with main color
so you just need to make main color increase and decrease
i mean make main color black and white with the same "matfh.pingpong" function
then the object's brightness is increase and decrease