マイロボット配置システム5








タワーに色をつける
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TowerController : MonoBehaviour
{
private void Update()
{
if(this.gameObject.tag == "BlueTower")
{
GetComponent<MeshRenderer>().material.color = Color.blue;
}
else if(this.gameObject.tag == "RedTower")
{
GetComponent<MeshRenderer>().material.color = Color.red;
}
}
}





テリトリーに色をつける
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeritoryController : MonoBehaviour
{
void Update()
{
if(transform.root.tag == "BlueTower")
{
this.gameObject.tag = "BlueTeritory";
GetComponent<MeshRenderer>().material.color = new Color(0.025f, 1, 1, 0.3f);
}
if(transform.root.tag == "RedTower")
{
this.gameObject.tag = "RedTeritory";
GetComponent<MeshRenderer>().material.color = new Color(1, 0.03f, 0.03f, 0.3f);
}
}
}




タワーの色を途中で変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TowerController : MonoBehaviour
{
private void Update()
{
if (this.gameObject.tag == "BlueTower")
{
GetComponent<MeshRenderer>().material.color = Color.blue;
}
else if (this.gameObject.tag == "RedTower")
{
GetComponent<MeshRenderer>().material.color = Color.red;
}
}
// ★追加
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "EnemyBot")
{
this.gameObject.tag = "RedTower";
}
else if (other.gameObject.tag == "MyBot")
{
this.gameObject.tag = "BlueTower";
}
}
}











タワーに色をつける
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TowerController : MonoBehaviour
{
private void Update()
{
if(this.gameObject.tag == "BlueTower")
{
GetComponent<MeshRenderer>().material.color = Color.blue;
}
else if(this.gameObject.tag == "RedTower")
{
GetComponent<MeshRenderer>().material.color = Color.red;
}
}
}





テリトリーに色をつける
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeritoryController : MonoBehaviour
{
void Update()
{
if(transform.root.tag == "BlueTower")
{
this.gameObject.tag = "BlueTeritory";
GetComponent<MeshRenderer>().material.color = new Color(0.025f, 1, 1, 0.3f);
}
if(transform.root.tag == "RedTower")
{
this.gameObject.tag = "RedTeritory";
GetComponent<MeshRenderer>().material.color = new Color(1, 0.03f, 0.03f, 0.3f);
}
}
}




タワーの色を途中で変える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TowerController : MonoBehaviour
{
private void Update()
{
if (this.gameObject.tag == "BlueTower")
{
GetComponent<MeshRenderer>().material.color = Color.blue;
}
else if (this.gameObject.tag == "RedTower")
{
GetComponent<MeshRenderer>().material.color = Color.red;
}
}
// ★追加
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "EnemyBot")
{
this.gameObject.tag = "RedTower";
}
else if (other.gameObject.tag == "MyBot")
{
this.gameObject.tag = "BlueTower";
}
}
}



マイロボット配置システム5