Error CS1501, Projectiles spawning.

My bullet projectiles are being fired from the turret, and ending up spawning ontop of another, furthermore they don’t move. I’ve tried adding Physics.IgnoreCollision(bullet.collider);

However that generates the error; error CS1501: No overload for method IgnoreCollision’ takes1’ arguments

void Update(){

 TargetEnemy(); // update the selected target and look at it

if (selectedTarget){ // if there's any target in the range...

transform.LookAt(selectedTarget); // aim at it

if (Time.time >= shootTime){ // if it's time to shoot...

Rigidbody bullet = (Rigidbody)Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);


}

1 Answer

1

Physics.IgnoreCollision() takes 2 or 3 arguments.

  • Physics.IgnoreCollision( colliderA, colliderB ) : colliderA and colliderB will not collide
  • Physics.IgnoreCollision( colliderA, colliderB, false ) : colliderA and colliderB will collide

Physics.IgnoreCollision(bullet.collider) is incorrect, you need to define what collider the bullet will ignore.

I see, so something like this? Physics.IgnoreCollision( bullet.collider, collider ); that doesn't give me the error anymore, but the bullets are moving just spawning ontop of one another. I take it that the above code is wrong.

You need to apply force to your bullet, after you instantiate it. [Rigidbody.AddForce()][1] [1]: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html

Okay, i literally want to hit myself. I had Is Kinematic checked on the rididbody, i've taken that off and the bullets are moving. However they are being fired at the ground now, not locked onto the target at all.

Check the bullet rotation and the force vector.

Disregard the above problem. I have messed about with the code some more and it works! =) can't thankyou enough. I'm pretty sure that also leads me onto a whole new problem =p enemies using colliders (which i can't take of due to the movement system i'm using) messing up the bullet destroy code. But i'll have a think of that myself, thanks again mate