Turkish Coffee
Member
Hey,
I have a ballista object that shoots an arrow when if statements are true like below;
and this is the only code that effects the image_speed of the ballista object
The problem is, the image_index of ballista object -which is a variable = instance_create(); type of object- is never equal to bare 10, but higher than 10 like in the screenshot below. So that makes it create multiple arrow objects which I don't want. How to deal with this?
I have a ballista object that shoots an arrow when if statements are true like below;
Code:
if (state == "ready" && (collision_line(x+24,y-8,x+TowerRange,y-8,oEnemy,true,true)) && canAttack == true ) //I'm using state to say if the ballista can attack or not but I just tried adding another variable..
{
image_speed = 0;
if ( (ballista.direction == dir) && (ballista.image_index == 10) ) //when I make this part "ballista.image_index == 10" to "ballista.image_index >= 10", it creates multiple objects
{
image_index = 0;
state = "reloading";
with (instance_create(x+11, y-(55.5), oBallistaArrow)) //Create the arrow x+11,y-(55.5) //(ballista.x-1,ballista.y-4,oBallistaArrow))
{
speed = 10;
direction = other.ballista.image_angle;
image_angle = other.ballista.direction;
other.canAttack = false;
}
}
}
Code:
if (state == "reloading")
{
ballista.image_speed = 0.1;
}
else if (state = "ready")
{
ballista.image_speed = 0;
}