Having the tricks spawn after eating a treat
This commit is contained in:
@@ -10,6 +10,7 @@ public class TrickController : MonoBehaviour
|
||||
[SerializeField] private float targetRefreshInterval = 0.4f;
|
||||
[SerializeField] private float consumeDistance = 0.35f;
|
||||
[SerializeField] private float wanderInterval = 1.2f;
|
||||
[SerializeField] private TrickController trickPrefab;
|
||||
|
||||
private Rigidbody2D body;
|
||||
private Transform target;
|
||||
@@ -144,15 +145,28 @@ public class TrickController : MonoBehaviour
|
||||
continue;
|
||||
}
|
||||
|
||||
var spawnPosition = hit.transform.position;
|
||||
Destroy(hit.gameObject);
|
||||
if (target == hit.transform)
|
||||
{
|
||||
target = null;
|
||||
}
|
||||
SpawnTrick(spawnPosition);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnTrick(Vector3 position)
|
||||
{
|
||||
if (trickPrefab != null)
|
||||
{
|
||||
Instantiate(trickPrefab, position, Quaternion.identity);
|
||||
return;
|
||||
}
|
||||
|
||||
Instantiate(gameObject, position, Quaternion.identity);
|
||||
}
|
||||
|
||||
public void SetCarried(bool carried)
|
||||
{
|
||||
isCarried = carried;
|
||||
|
||||
Reference in New Issue
Block a user