|
Would it be possible to have something like this: http://newgrounds.com/portal/view/417593 where the projectiles are shot at a set time interval (for example: every half second) at a set velocity without the need for mouse input?
(comments are locked)
|
|
Absolutely! Take a look at InvokeRepeating. You can use it to repeatedly call the specified function at a given interval. The function that you call could spawn the projectile with a default velocity. The script you've posted in the comments seems to be a bit of frankencode, but from it I think I can see what you're trying to do with it. I think this is closer to what you want:
If you don't understand any particular part, check out the Scripting Reference or comment back! Thank you. When I tried that script and selected a projectile, after that projectile was shot, the next one would be shot originating from the first projectile, and then the third projectile was shot from the second, etc. How can I make it so that it always shoots from the player (I added the script to the player object)?
Nov 15 '10 at 03:41 AM
Tyler 2
If the script is on the player object, use 'transform.position' to get the current position of the player. If you're having troubles, update your question with your code and I can give you a more specific answer!
Nov 15 '10 at 06:54 AM
Marowi
// Starting in 2 seconds. // a projectile will be launched every 0.3 seconds var projectile : Rigidbody; InvokeRepeating("LaunchProjectile", 2, 0.3); function LaunchProjectile () { var instance : Rigidbody = Instantiate(projectile); instance.velocity = transform.position; transform.rotation ; instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) ); Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider ); } This script is the one you linked me to spliced with another script that fires when I click down.
Nov 16 '10 at 12:21 AM
Tyler 2
I think you're missing some of your code. 'transform.rotation' isn't being set, and theirs no definition for 'instantiatedProjectile'.
Nov 16 '10 at 01:48 AM
Marowi
I've updated my answer with some example code based on yours.
Nov 16 '10 at 01:52 AM
Marowi
(comments are locked)
|
