- Home /
Can I make an Enemy Insatiate a projectile object?
Can I make my enemy robot shoot projectiles if the enemy has a collider on it?
I used this code for the enemy weapon and it didn't work (bear in mind the number which allows the enemy to shoot is just the AI saying the player is near)
var speed : float = 7.0; var atkspeed : float = 0.36; var ready : boolean = false; var timer : float = 0.0; var projectile2 : Rigidbody;
function Update () { timer += Time.deltaTime; if (timer > atkspeed) { ready = true; } if (ready){
if (EnemyStats.atkb == 2){
var instantiatedProjectile2 : Rigidbody = Instantiate( projectile2, transform.position, transform.rotation );
instantiatedProjectile2.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
timer = 0.0;
}
}
}
Answer by 3dDude · Jan 07, 2011 at 01:38 AM
Your projectiles might be colliding with your enemy collider.. try adding this script to the projectile...
try playing around with this script:
http://www.unifycommunity.com/wiki/index.php?title=CollisionIgnoreManager
Thanks man, actually solved it short after posting the question, and yea that was the problem