Its a "Script Function"If you call a plain function (not a struct function) from an instance Step or Create event (for example) and your function sets alarm 0 to some value, that alarm should be set. Might want to post complete code for your attempt.
function blood(dmg,spd,objhiting,objhited)
{
rd = irandom_range(dmg,dmg*2)
repeat(rd)
{
//where alarm should go lol
with(instance_create_layer(objhited.x,objhited.y,"Instances_projectile",obj_blood))
{
speed = spd/3
direction = point_direction(objhiting.x,objhiting.y,objhited.x,objhited.y)
direction += irandom_range(-40,40)
}
}
}
with()
statement? If the instance calling the function, doesn't make sense to do it in the loop, but rather before or after it. For created instances, set it inside the with()
statement code block (since that code runs in the context of the newly created instance).with(instance_create_layer(objhited.x,objhited.y,"Instances_projectile",obj_blood))
{
speed = spd/3
direction = point_direction(objhiting.x,objhiting.y,objhited.x,objhited.y)
direction += irandom_range(-40,40)
}
Ty for the tips!If you want a delay before obj_blood is created, you'll have to have this code:
Inside of the alarm in the calling instance, and then simply set that alarm in the function. I think you're trying to do the old thing where people think "Ah, if there's some sort of loop here, it'll create a delay", when that's not how loops work.Code:with(instance_create_layer(objhited.x,objhited.y,"Instances_projectile",obj_blood)) { speed = spd/3 direction = point_direction(objhiting.x,objhiting.y,objhited.x,objhited.y) direction += irandom_range(-40,40) }
Ty u too!Thanks @RefresherTowel, I completely misunderstood the question at hand.