One shot per key down or shooting until key is released?
The first version is easy:
make a key down event, add the key(s) to press for shooting, repeat: disabled and then select script editor.
Put this into the script:
- Code: Select all
CreateActor("shot", "animation", "(none)", "(none)", 0, 0, false);
This create a shot every time you press the key.
If you want to shoot until the key is released, there are two ways: a timer or controlling it in the scrip.
The timer is better for the performance.
You put this instead of the other script:
- Code: Select all
CreateTimer("Event Actor", "name", 30);
Add an timer event and put the first code in the script edtior.
This will create a shot every 30 frames, with 30 fps is this one shot per second.
The other way is a bit more complicating:
make a key down event, add the key(s) to press for shooting, repeat: enabled and then select script editor.
put this in it:
- Code: Select all
x = x + 1;
if(x == 30)
{
CreateActor("shot", "animation", "(none)", "(none)", 0, 0, false);
x = 0;
}
This should also create the shot every second, because the variable (x) is increased every frame, the shot is created in every 30th frame.
Both ways should work, but i didn´t test it.
I hope i could help.