*Hello,
Im doing a college project in which I have to send OSC messages to Pure Data, I need that object to re-spawn once it is destroyed by the collision with the ball (player)… Once the ball collides with the object, OSC is sending 1000s of messages to pure data instead of one. I want a single message to be sent when I hit the coin and then I want the coin to then, re-spawn.
This is the code!
#pragma strict
var coinEffect : Transform;
var oscRef : OSCTestSender2Jump;
var respawnTimer : float;
var collectedItem : float;
var delayTime : float;
var objectPrefab : Transform;
function OnTriggerEnter (info : Collider)
{
if (info.tag == “Player”)
{
Debug.Log("Add coin counter here!");
Instantiate(coinEffect, transform.position, transform.rotation);
oscRef.coinCollide();
Destroy(gameObject);
if(collectedItem){
respawnTimer += Time.deltaTime;
if(respawnTimer > delayTime){
var newObject = Instantiate(objectPrefab, transform.position,
transform.rotation);
respawnTimer = 4.0;
}
}
}
}
Thanks!