instaniated collision or trigger

I have a instaniated bullet that is created on fire however it does not detect a triiger event or a collider event not sure any ideas?

CODE

var projectile : Rigidbody;
var speed = 20;
var ammoCount = 10;
var lastShot = 0.0;
var reloadTime = 0.5;
var lightonnoff;

function Update () {

if (Input.GetKeyDown (“space”)) {
if ( ammoCount <= 0)
return;//stops the code in its tracks when the above conditions are met

lastShot = Time.time;
ammoCount–;
var instantiatedProjectile : Rigidbody = Instantiate (projectile,

transform.position,
transform.rotation);
instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0,-30,0));
// Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
//gravity down makes ball arc
Physics.gravity = Vector3(0, 0, 20);

} }

Does the “Bullet” Have a collider?
AC

when i put a collider on it it comes up with a error message
NullReferenceException:The prefab you want to instantiate is null

Hmmm I expect this is from the fps tutorial. I found I had to do the whole thing 3 times before I started understanding it.

I wonder: See this line:

// Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);

You have it commented out, maybe with it commented out, the bullet instantiates, then is destroyed straight away, because its colliding with your character, then the next line is throwing an error because its trying to instruct an object that doesnt exist anymore.

You can change:

transfom.root.collider to transform.collider or transform.parent.collider too, which ever suits your setup.

Sorry I cant help much more without a unityPackage example or small project folder.

AaronC

cheers for your help getting there it kind of works without throwing any errors up
but when the game starts the player object automatically recoils as if it has hit something

I put parent in as instructed

instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0,-30,0));
Physics.IgnoreCollision(instantiatedProjectile.collider, transform.parent.collider);

Appreciate your help bud

got it to stop throwing up errors just needed to update the debug console window however on game start a bullet that i have not even fired drops through the player object and causes it to recoil??

was thinking to patch it by creating a delay on the physics on start of game start is that possible and would it be advisable?

set the rigid body material to metal not sure why it solved the problem i guess it magic but any how cheers for help bud your biggest fan

Cat

If your Bullet exists in the scene before you press play, you need to create a prefab(In the Project view)then Drag you scene-bullet onto it, then delete your scene -bullet. Then assign the new prefab from project view onto your launcher slot in the inspector.

Or maybe your player object is intersecting with level geometry on play and is getting bumped free on play?

I cant see why a random bullet would appear and bump you when none of the instantiated bullets do that…

Keep going!Im off to bed so cant help for 12 hours at leastzzzzzzzzzzzz
AC