View Full Version : Firing a laser blast from a cannon. (Specifically for an X-Wing)
12-03-2009, 01:16 AM
Long story: Hi, I am currently trying to make a rig for an x-wing that I built and part of my assignment is to make it fire laser bolts. I've written a script that executes the pattern for firing and it works correctly. I know this because I have recoil and muzzle flashes also set up. Those are working. Theoretically, if there was a command that said something to the effect of, "emit particle emitter1;" then I would have solved the problem. Unfortunately my school has offered me no solution whatsoever and I've had a hard time finding a way to do it on the internet. I'm currently using instanced particles, but I am open to other solutions. I've tried having the particles' max count (opposed to being -1) increase every time I get to the correct part of the code, but I have to kill the particles eventually which will kill that method anyway.
Short story: I need to know a way to fire a laser from a source that will continue on its original vector independent to the the orientation or position of the rig it originated from.
I've uploaded a video to show my script controlling the cannons' recoil and muzzle flashes. Thanks for any help you can give me.
P.S. For the hardcore Star Wars fans: Being a huge SW fan myself, I understand x-wing turrets neither recoil nor produce muzzle flashes. My teachers forced me to do it against my... well vocalized arguments. In the end I lost and ended up making the system even though those hypocrites didn't have a solution for me anyway... :buttrock:
I'm not sure if I understand you correctly... but have you looked in the docs at the command called "emit"?
It's not used to tell an actual emitter anything. It simply creates particles, and you specify what particleObject will contain those new particles, and what velocity etc. they will have at birth.
12-03-2009, 07:48 PM
That is a little confusing. Would writing some code that said: If the muzzel_mesh translateX was greater than zero then set the emitter.rate to 1000 otherwise set it to 0 work for you? That way you could change the timing of your muzzel animation and your emitter will follow suit.
12-04-2009, 12:53 AM
Thanks for the help guys. I looked into the emit command and it seems like I can make this work. I can make a single particle shoot every time I run the command, which is perfect. Unfortunately I haven't quite figured out how to instance particles made this way. I will keep trying, but if anyone does have a way do this I'm all ears.
By the way, sorry for the confusion. My basic question is how do people make laser beams shoot from a gun/cannon?
The path I'm on now looks viable but I feel like there must be some kind of standardized way to do this.
12-04-2009, 01:29 AM
Sorry for the double post. Being a new member, my replys need to be approved. The emit command solution is working flawlessly. It turns out the newly created particles DO inherit the instancing attributes, I simply have to play the animation to see the results.
12-04-2009, 05:43 PM
If you wish to use an emmiter, setting the rate to the same value as your frames/second, for a single frame, will emit a single particle.
12-04-2009, 05:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.