I have tried Unity Answers without success and now I’m asking for your help.
I have a modified version of the BustedBox script from some FPS tutorial. It looks like this:
var explosion : Transform;
var deadReplacement : Rigidbody;
var clip : AudioClip;
function OnMouseDown () {
BroadcastMessage ("Detonate");
}
function Detonate () {
AudioSource.PlayClipAtPoint(clip, Vector3 (5, 1, 2));
// Destroy ourselves
Destroy(gameObject);
// Create the explosion
if (explosion)
Instantiate (explosion, transform.position, transform.rotation);
// If we have a dead barrel then replace ourselves with it!
if (deadReplacement) {
var dead : Rigidbody = Instantiate(deadReplacement, transform.position, transform.rotation);
// For better effect we assign the same velocity to the exploded barrel
dead.rigidbody.velocity = rigidbody.velocity;
dead.angularVelocity = rigidbody.angularVelocity;
}
// If there is a particle emitter stop emitting and detach so it doesnt get destroyed
// right away
var emitter : ParticleEmitter = GetComponentInChildren(ParticleEmitter);
if (emitter) {
emitter.emit = false;
emitter.transform.parent = null;
}
}
// We require the barrel to be a rigidbody, so that it can do nice physics
@script RequireComponent (Rigidbody)
But when I use “Drag Rigidbody” on the replaced object (The object which spawns after I used this script) I get these error messages:
… and the I can’t lift and move the rigidbody as I want.
Please help me out