Hello, I have a long question but I while try to be as concise as I can. I am making a 2D Shooter (like geometry wars, super stardust HD, etc.). I have used a script to make the player object rotate/look in a direction depending on the mouse cursor position relative to the camera (so if the mouse cursor is above the object on the screen it is facing up, and if a move the mouse clockwise, the object will rotate clockwise). I have attached the following script to the object that rotates,
var projectile : Rigidbody;
var speed = 20;
function Update()
{
if( Input.GetButtonDown( "Fire1" ) )
{
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
}
}
It makes it so that when I click the mouse, a projectile moves forwards(up along with the default view) from the object that rotates. But, since I used another script to rotate the object, the projectile moves towards the mouse (because the mouse direction is now its forward direction). I want to modify the script (the one posted above) to do either of the following
1:Fire every .5 second, regardless of whether the mouse is held down or not. 2:Fire every .5 second when the mouse is held down (not just pressed once, but held down).
I have tried instantiate scripts and stuff like that, but they seem ignoring the rotation of the object. Thank you for reading my long post. :)