我需要使我的GameObject(拾取)在玩家进入触发器并按x拾取时被破坏。
这是我到目前为止所掌握的。 这是需要销毁的皮卡:
<html>
<body>
<head>
<title>
View Books
</title>
</head>
<body>
<table border=2>
<tr>
<th>Book ID</th>
<th>Title</th>
<th>Author</th>
<th>No. of copies AVAILABLE</th>
<th>Number of favourites</th>
</tr>
<tr>
<td><%=b.bookID%></td>
<td><%=b.bookTitle%></td>
<td><%=b.bookAuthor%></td>
<td><%=b.bookCopies%></td>
<td><%=b.bookFavs%></td>
</tr>
<%
}
%>
</table>
</body>
</html>
这是在与拾音器的触发器发生冲突的播放器上:
public void Update()
{
if (UIManager.XButtonPressed == true)
{
UIManager.AbleTopickUp = false;
UIManager.XButtonPressed = false;
Destroy(this.gameObject);
Debug.Log("Destroyed the pickup.");
}
}
void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.name == "Player")
{
UIManager.AbleTopickUp = true;
}
}
void OnTriggerExit(Collider collision)
{
if (collision.gameObject.name == "Player")
{
UIManager.AbleTopickUp = true;
}
}
任何帮助将不胜感激
答案 0 :(得分:0)
将OnTriggerEnter
替换为OnTriggerStay