Copy link to clipboard
Copied
I am creating a real time fighting game, and on the stage I have two boundary boxes (MovieClips). There are also two character MovieClips, each added as a child to their respective boundary box through the timeline code. In each of these MovieClips, there is a hitbox, which, for certain animations, has it's .visible property set to false. What I need is for a boundary box to detect when it is being hit by a visible hitbox, and then run the damage function based on a variable which is set in the animation.
How do I do that?
Every time I try hitTestObject(MovieClip(parent).box.char.hit) it tells me that it doesn't exist.
then you've to active the .hitTestObject method only during the attack because in all cases if the character box visibility is false or true it will be damaged when the touch happening.
Copy link to clipboard
Copied
- set the hit box visible to true and use alpha = 0 instead.
- hit test:
if(box1Name.hitTestObject(
box2Name
))
{
// run the damage function
}
Copy link to clipboard
Copied
But then if the box touches the enemy during a non-attack animation, it will be damaged.
If I remove the frames containing the invisible hitbox, I get a lot of errors saying it can't find the object.
The check for the boundary hitting the hitbox is run every frame through an event listener.
Copy link to clipboard
Copied
then you've to active the .hitTestObject method only during the attack because in all cases if the character box visibility is false or true it will be damaged when the touch happening.
Copy link to clipboard
Copied
Ok, that'll do it!
Thanks!
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now