T
T-Radar
Guest
Hello all
I have been following the basic "Space Rocks" Tutorial (I've finished the "factions" section) and the script for creating bullets from before the 2.3 update was:
After updating to 2.3, the script was automatically updated to a function but the bullets did not appear.
I saw the changes to scripts in this new version and tried to adapt the script correctly, ending up with this:
But the bullets still did not appear, although the sound plays every time I fire a bullet.
I tried the debbuger and all the variables seem to have the correct values and the object is marked as "visible".
Other odd things happened:
- When going in high speed with my ship and facing the other way... sometimes the bullets do appear briefly.
- When using the following piece of code on the step event of the ship (it's wrong but used it for debbuging):
The first bullet shows up (the one created by the create_bullet function) and the second one (created using the instance_create_layer) destroys my own ship (since it collides with it upon creation and the bullet in this case has an undefined "faction").
How can I fix my function in order for the bullets to appear?
Thank you in advance for any help.
I have been following the basic "Space Rocks" Tutorial (I've finished the "factions" section) and the script for creating bullets from before the 2.3 update was:
GML:
var _dir = argument[0];
var _spd = argument[1];
var _fac = argument[3];
var _creator = id;
audio_play_sound(snd_zap,1,false);
var inst = instance_create_layer(x,y,"Instances",obj_bullet);
with(inst)
{
direction = _dir;
speed = _spd;
faction = _fac;
creator = _creator;
if(faction == factions.ally) image_blend = c_aqua;
else if (faction == factions.enemy) image_blend = c_red;
}
After updating to 2.3, the script was automatically updated to a function but the bullets did not appear.
I saw the changes to scripts in this new version and tried to adapt the script correctly, ending up with this:
GML:
function create_bullet(_dir, _spd, _fac)
{
var _creator = id;
audio_play_sound(snd_zap,1,false);
var inst = instance_create_layer(x,y,"Instances",obj_bullet);
with(inst)
{
direction = _dir;
speed = _spd;
faction = _fac;
creator = _creator;
if(faction == factions.ally) image_blend = c_aqua;
else if (faction == factions.enemy) image_blend = c_red;
}
}
I tried the debbuger and all the variables seem to have the correct values and the object is marked as "visible".
Other odd things happened:
- When going in high speed with my ship and facing the other way... sometimes the bullets do appear briefly.
- When using the following piece of code on the step event of the ship (it's wrong but used it for debbuging):
GML:
if(keyboard_check_pressed(vk_space))
{
create_bullet(image_angle, bulletSpd, faction);
var inst = instance_create_layer(x,y,"Instances",obj_bullet);
}
How can I fix my function in order for the bullets to appear?
Thank you in advance for any help.