- Home /
My rockets don't do damage?
When I shoot my rockets at an Ai the dont do any damage, how do I change that? I used the standard script from the FPS Turtorial, I had to make a madofication to it so that my rocket would shoot farther, I deleted the second part of the script,that started with FunctionUpdate. Did I delete the part needed to deal damage? This is what my script looks like:
// The reference to the explosion prefab var explosion : GameObject; var timeOut = 8.0;
function OnCollisionEnter (collision : Collision) { // Instantiate explosion at the impact point and rotate the explosion // so that the y-axis faces along the surface normal var contact : ContactPoint = collision.contacts[0]; var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal); Instantiate (explosion, contact.point, rotation);
// And kill our selves
Kill ();
}
function Kill () { // Stop emitting particles in any children var emitter : ParticleEmitter= GetComponentInChildren(ParticleEmitter); if (emitter) emitter.emit = false;
// Detach children - We do this to detach the trail rendererer which should be set up to auto destruct transform.DetachChildren();
// Destroy the projectile Destroy(gameObject);
}
@script RequireComponent (Rigidbody)
This is a great example of a bad question, that provides little to no detail about the problem.
When I shoot my rocketlaunchers projectile it hits the enemies, but no damage is given. I want the rocket to be a One-Hit, but it has no damage giving properities.
What's the problem? Have you written some code for this and it's not working, or are you at a loss as to how to proceed? And please update your answer with details, ins$$anonymous$$d of commenting.
Answer by Clave · Jun 25, 2010 at 10:57 PM
you have to add this script on the prefab "explosion" your instantiating in this line of yours
Instantiate (explosion, contact.point, rotation);
then you just have to tweak some parts like add the ability of your AI to receive damage, the proper Collider tags so when the explosion happens, it knows who receives damage.
Your answer
Follow this Question
Related Questions
Ai Aint Taking Damage From Bullet (FPS Rocket) 1 Answer
AI Damage if touched 1 Answer
FPS Tutorial AI Damage not Working 1 Answer
Setting up smart damage taking in game... 2 Answers
The enemy don´t lose health, but why??? 0 Answers