#material value doesn't change at runtime

1 messages · Page 1 of 1 (latest)

safe sable
#

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));
    }
}

#

it is changing in game, only if i click and drag the value

#

material value doesn't change at runtime

thorny stirrup
safe sable
#

actually the starting value is 0 at mathf.pingpong

#

also the value is changing everytime when i don't touch, you see

thorny stirrup
safe sable
#

i don't think it's about codes or something like that simple, it's probably about shaders or some systemical thing

thorny stirrup
#

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.

safe sable
#

ok, it didn't fix but thanks anyway.

#

anyone else has an idea?

safe sable
#

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