rigidbody velocity problem

I have a script that fires projectiles, and just earlier today it worked, but it just stopped working for no reason, so i tried to debug it, and the script says the velocity is this:

(here is the script

var projectile : Rigidbody;
var barrel1 : Transform;
var barrel2 : Transform;
var canFire : boolean;
var initialSpeed = 30;

var fireRate = .01;

function Update () {
	canFire = Turret.on;
	
	if (canFire == true) {
		if (Input.GetButton("Fire1")) {
			SendMessage("fire");
		}
	}
}

function fire () {
	var projectile1 : Rigidbody = Instantiate(projectile, barrel1.position, barrel1.rotation);
	projectile1.velocity = transform.TransformDirection(Vector3 (0, initialSpeed, 0));
	Debug.Log("velocity1 = " + (projectile1.velocity));
	
	yield WaitForSeconds(fireRate);
	
	var projectile2 : Rigidbody = Instantiate(projectile, barrel2.position, barrel2.rotation);
	projectile2.velocity = transform.TransformDirection(Vector3 (0, initialSpeed, 0));
	Debug.Log("velocity2 = " + (projectile2.velocity));
	
	yield WaitForSeconds(fireRate);
}

)

What is “working” behaviour and what is “non-working” behaviour?

well, apparently the velocity part right after the prefabs are instantiated.

What were the velocities supposed to be?

It would help if you would give us:

  1. The direction you shoot in.
  2. The velocities it should have, given the direction.
  3. The velocities it actually has.

Do this in multiple directions, then post the results.

Otherwise, can the projectile collide with the barrels?

no, the projectile cant collide with the barrels, the barrels have no collider attached. im trying to shoot forwards. it should have 0, 30, 0 velocity. the picture i posted has the actual velocities it has.

Can you explain what this means?
How did you try to fix it?

Which velocity should we be looking at to determine what went wrong?

ignore that, it has nothing to do with anything. i dont know what went wrong, but it seems to either be destroying itself 1 second after it gets spawned. I now think i know the problem, though. I made a big box collider, set it as a trigger, and that might of done it. can things that are labeled OnTriggerEnter collide with other triggers and execute the code in the functions?

A quick search brings up:

“Be aware that in order for two Triggers to send out trigger events when they collide, one of them must include a Rigidbody as well” - Unity Manual

Does one of your objects have a Rigidbody? If so, it would call the function.

dang, that sucks. how could i make a checkpoint that doent affect triggers with rigidbodies?

If you do not want a Rigidbody to detect collisions, you can turn collision detection off.

rigidbody.detectCollisions = false;

well, its a bullet, and would that affect the collider(trigger) from detecting collisions?

Unfortunately, yes it would, but first, disable the collision detection and see if it works like you want. Then you can decide whether you want to change the design, or disable collision detection and re-enable it when it is so far away.

maybe i could tag the checkpoint checkpoint, and then make it so it ignores the collision? i know how to do it, and i think it would work?

I don’t see any reason why that shouldn’t work. But first you should simply disable collisions and make sure thats the problem.

i deleted the checkpoint, and it now works