x


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;

        }
    }
}
more ▼

asked Jan 06 '11 at 11:07 PM

AtomicMarine gravatar image

AtomicMarine
587 46 57 77

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jan 07 '11 at 01:38 AM

3dDude gravatar image

3dDude
2.8k 69 81 105

Thanks man, actually solved it short after posting the question, and yea that was the problem

Jan 07 '11 at 03:24 PM AtomicMarine
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3681
x952
x331

asked: Jan 06 '11 at 11:07 PM

Seen: 1179 times

Last Updated: Jan 06 '11 at 11:07 PM