Projectiles Tutorials

tox_von

Member
ive done a basic tutorial on how to make arrows but i need to know how to limit there distance traveled and how to make them disapear after a certain amount of time. I think this is done with an instance destroy but what is the code i need or is there a tutorial with this also? Also how do i make it so only one can be shot at a time.
 

FrostyCat

Redemption Seeker
Shouldn't that "basic tutorial" have taught you to use step checks and alarms by now?

Limiting travel distance is easy with something like this in the Step event:
GML:
if (point_distance(x, y, xstart, ystart) >= 500) {
    instance_destroy();
}
Disappearing after some time is just something like this in the Create event:
GML:
alarm[0] = 6*room_speed;
And this in the Alarm 0 event:
GML:
instance_destroy();
And shooting just one arrow at a time is just adding an instance_exists check to the shooting key check:
GML:
if (keyboard_check_pressed(vk_space) && !instance_exists(obj_arrow))
 

tox_von

Member
i tried adding this but i dont know the code what do i do?

if (mouse_check_pressed(mb_left) && !instance_exists(Object2))

if mouse_check_button(mb_left) instance_create_layer(x,y,layer,Object2)
 

FrostyCat

Redemption Seeker
GML:
if (mouse_check_button(mb_left) && !instance_exists(Object2)) {
     instance_create_layer(x, y, layer, Object2);
}
If you still don't know how to use basic syntax, stop whatever you are doing and learn that first. Also, learn to use the Manual, don't rely on the forum for every little thing.
 
Top