I know the way I’m moving the position of where the particles spawn has to be wrong. I’m attaching a rigidbody to the prefab that contains my particle system. I attach a script that contains this code for moving the particles.
Rigidbody newBullet = (Rigidbody)Instantiate( particleBullet, transform.position, transform.rotation );
newBullet.velocity = transform.TransformDirection( new Vector3( 0, 0, -initialSpeed ) );
Obviously this isn’t the best way, and probably not the fastest. What is a better way to achieve the same effect (I tried looping through all the particles of the particleEmitter and changing the velocity like above, but that didn’t do anything)?
Thanks,
Jedd
I’m not sure I follow what you’re trying to do here. Is a bullet a particle, or does it emit particles?
sorry, newBullet is the prefab that contains the particle system and the rigidbody.
I think you’re looking for
var force : float = 100.0;
var newBullet : GameObject = Instantiate(Bullet, transform.position, transform.rotation);
newBullet.rigidbody.AddRelativeForce(newBullet.transform.forward*force, ForceMode.Impulse);
Set your particle emitter to “Simulate in Worldspace” true and the particles will spray off the bullet, else they will travel with the bullet - depends on your desired effect.
Cheers,
Well, the whole point was to achieve the same effect I have, without the rigidbody. The particle system is the bullet, so basically I have rigidibody attached to a particle system, which doesn’t make much sense 
Nothing particularly wrong with having particle effects with rigid bodies. All the bullets in my game Phoenix Final work in that way.
If you really don’t want a rigid body, write a script which uses Transform.Translate() to move the object around instead.
The only reason I don’t want it is because I thought having a rigidbody would be less efficent. Maybe the cost isn’t that great?
RB’s are not a problem. It’s collision testing and raycasting that you want to reduce. With bullets you’re going to want to raycast. Any GameObject that moves a large distance per game step will/may pass straight through your collision test. Raycasting isn’t too expensive but you still need to use it wisely.
Well, you’re trading off the (relatively small) overhead of the native code physics engine against the (relatively small) overhead of a Mono script. I haven’t measured the difference, so I don’t know which is really most efficient, but my point is that both features have some degree of cost. There’s no completely free way of moving an object. You might as well use whichever’s easiest, instead.