1100107 碰到物體時讓物體變透明
by 黃國哲 2021-01-07 11:00:20, 回應(0), 人氣(564)
https://blog.csdn.net/weixin_44302602/article/details/103552552
private Color StartColor;
private void Start()
{
StartColor = BarraryObjecrt.GetComponent<Renderer>().material.color;//其中的BarraryObjecrt是墙体
}
private void ProcessMode2()
{
transform.LookAt(Player.transform);
transform.position = Player.transform.position + offset;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 1000))
{
if (hit.collider.tag == "Player")
{
isBall = true;
}
else
{
isBall = false;
}
}
if (!isBall)
{
hit.collider.gameObject.GetComponent<Renderer>().material.color = new Color(1, 1, 1, 0.75f);
}
else if (isBall)
{
hit.collider.gameObject.GetComponent<Renderer>().material.color = StartColor;
}
}
回應