brinycann0nade
Member
I have a hay bale that if you stab, it emits have particles out of the side. The emitter works perfectly fine so I don't think that's the issue. When the emitter is created, it plays two frames and then destroys itself.
I want the stab of the obj_player to only activate the "create emitter" code once. I was able to accomplish this with similar code earlier today when I was trying to get the emitter to work, but I since deleted it since I didn't need it anymore. The problem is that the stab is a few frames long meaning it obj_player keeps contact with the hay bale for a bit so it wants to register a hit a number of times per second. Because of that, it creates more than one emitter. It should be one stab, one emitter creation.
I think the code I have almost works but something is out of order.
Create Event of obj_hayBale
stab = false;
counter = 0;
Step Event of obj_hayBale
I want the stab of the obj_player to only activate the "create emitter" code once. I was able to accomplish this with similar code earlier today when I was trying to get the emitter to work, but I since deleted it since I didn't need it anymore. The problem is that the stab is a few frames long meaning it obj_player keeps contact with the hay bale for a bit so it wants to register a hit a number of times per second. Because of that, it creates more than one emitter. It should be one stab, one emitter creation.
I think the code I have almost works but something is out of order.
Create Event of obj_hayBale
stab = false;
counter = 0;
Step Event of obj_hayBale
Code:
if (obj_player.myState == STATE_PLAYER.stab) or
(obj_player.myState == STATE_PLAYER.walkstab) or
(obj_player.playerFightLockState == STATE_PLAYER_FIGHTLOCK.stab) or
(obj_player.playerFightLockState == STATE_PLAYER_FIGHTLOCK.walkstab) and //if obj_player has his sword out (obj_player has a timer that makes him hold out his stab animation for a quarter of a second)
(place_meeting(x, y, obj_player))
{
stab = true;
if (counter < 1)
{
counter++; //ticks up to 1 if collision is initiated. It's supposed to keep the collision from activating 60 times a second.
}
if (stab == true) and (instance_number(obj_emitter) == 0) and (counter == 1) //if his sword is out, and there's no other emitters, and collision has only happened once then do this:
{
instance_create_layer(x, y-25, "Instances", obj_emitter);
stab = false;
}
}
counter = 0;