Question by
Delidragon · Mar 19, 2018 at 01:45 PM ·
scripting problemtriggermaterialrendererblending
Blend to other Material on Trigger Event
heyho when i press on my gameobject i want that his current material blend in one other material and back after you pressed again pls help i tried this but it wont work some ideas ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class materialchanger : MonoBehaviour {
public Material material1;
public Material material2;
public float duration = 2.0F;
public Renderer rend;
void Start() {
rend = GetComponent<Renderer>();
rend.material = material1;
}
public void clickblendshphere() {
float lerp = Mathf.PingPong(Time.time, duration) / duration;
rend.material.Lerp(material1, material2, lerp);
}
}
screenshot-11.jpg
(100.2 kB)
Comment
Your answer
Follow this Question
Related Questions
How would I change material properties of a box collider via script? 0 Answers
material color not changing 1 Answer
Increase enemy speed when it sees the player 0 Answers
Gameobject Renderer not working. 1 Answer
How to load material onto sphere? 1 Answer