-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathColorChange.cs
35 lines (28 loc) · 917 Bytes
/
ColorChange.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class ColorChange : MonoBehaviour
{
public bool upTodown = false;
void Update()
{ // check every frame
if (Input.GetKeyDown(KeyCode.Space))
{
upTodown = true;
}
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("Bridge"))
{
Color newColor = new Color(Random.value, Random.value, Random.value, 1.0f);
gameObject.GetComponent<Renderer>().material.color = newColor;
}
if (other.gameObject.CompareTag("Plain") && upTodown == true)
{
Color newColor = new Color( Random.value, Random.value, Random.value, 1.0f );
gameObject.GetComponent<Renderer>().material.color = newColor;
upTodown = false;
}
}
}