您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
725 B
26 行
725 B
//Detect when the orange block has touched the goal.
|
|
//Detect when the orange block has touched an obstacle.
|
|
//Put this script onto the orange block. There's nothing you need to set in the editor.
|
|
//Make sure the goal is tagged with "goal" in the editor.
|
|
|
|
using UnityEngine;
|
|
|
|
public class GoalDetect : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// The associated agent.
|
|
/// This will be set by the agent script on Initialization.
|
|
/// Don't need to manually set.
|
|
/// </summary>
|
|
[HideInInspector]
|
|
public PushAgentBasic agent; //
|
|
|
|
void OnCollisionEnter(Collision col)
|
|
{
|
|
// Touched goal.
|
|
if (col.gameObject.CompareTag("goal"))
|
|
{
|
|
agent.ScoredAGoal();
|
|
}
|
|
}
|
|
}
|