Error in code(Melee Attack)

Thanks, but a few questions:

  1. How should I disable and then enable behaviours (I have platformer character behaviour)?
  2. By “animation is attack and animation has finished to change back to idle.”, do you mean:
    Condition:
    If one of these condition true:
    animation is attack
    And all of these condition true
    (Frame Condition and animation check)
    The animation finished
    Events:
    Disable Behaviour
    Delete attack Hitbox
    change animation to idle
    enable behaviour


try this - ive added a variable for attack
add a trigger once on the frame 6 event!

Thanks, I’ve done it now, this is how my events look like:


This is my preview:

(I put it in a canva presentation because the .gif size is too big)

As you can see, sometimes, it works, sometimes it doesn’t.

Ok - try it with no trigger once under the attack false.
If that doesn’t work its the ‘is animation finished’ - because it doesnt have - an animation =‘attack’ condition
If that doesn’t work - start a timer when you press s and set attack false based on that being great than .6s.
If that doesn’t work turn attack to a number variable
press s and set it to 60
attack>0 then attack=attack-1
attack=0 - delete the bloomin kick thing
if that doesn’t work offer the nearest jellyfish some parsnip soup and beckon him with a smile as the universe is now salad.
Edit .,… probably needs an animation is attack condition where you check the frame to create and check collision!

I removed the Trigger Once, and now its working amazing.
Thanks soo much :smiley:

I have another question tho,


A have another set of events where the leaf ranger shoots an arrow out of his bow and the arrow changes its “x” every second. I want to integrate the hitbox too but it’s not working. In the preview, the ranger just shoots the arrow, and I don’t see the hitbox even getting created.
Do you have any idea why this is happening?

Great - removing the trigger once was a bit of a bodge (the more senior code advisors here might tut disapprovingly) as it’s checking to delete every frame now - and that’s probably why it’s deleting the hitbox with attack2 - attack=false then delete the hitbox.
Have another variable for attack2 and possibly either another hitbox or have
attack=false and attack2=false then delete hitbox.
Did you try specifying the animation name in the conditions to delete the hitbox before while attack was true?

It might be worth setting the current frame to zero on key press…I can’t remember whether you’re doing this already

I tried doing that, but it didn’t work.
I also had an idea to just finish the hitbox and check collision with arrow but that also isn’t working.

Hi …I usually do pretty much everything with number variables that count down and trigger stuff and I don’t use animation frame is as a condition that often. I’m at work so can’t digest it properly but it looking at that as you’ve got it there I’m not sure whether you can create an object and check a collision in the same event
…I don’t know.
but that’s what you’re relying on there as frame 8 if attack …create and check collision and the very next event if frame 8 …change animation back to idle. Probably need a trigger once on the create arrow event.
I’ll look at it again later.

Hello,
Instead of putting the collision check in a sub event, I put it as a separate event - and it worked!


Thanks alot for your help so far with the melee attack and this, I was really stuck on it but in the end it felt so simple.

1 Like

Great - You just need to get used to reading events and subevents top to bottom and thinking about what you’re asking the computer to do. It’s like - looking at the above. You’re asking is animation attack2 and is it frame 8 and then in the next event asking the same question again and so it makes more sense to ask it once then set ani to idle (turn platform character animator back on here) and then have is flipped and is not flipped as sub events of - is animation attack2 and is it frame 8 - create the arrow and add the force.
By the way - your attack collision could be an object that moves away from player for a few frames before deleting. If you create a point on player called ‘hitbox’ on frame 8 and create hitbox there, and apply a force at angle between player and point ‘hitbox’ then you wouldn’t need to check if it’s flipped and the hitbox could be visible with opacity 100 - might look nice

1 Like

Thanks - gonna use that :smiley: