Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

hitTestObject as a Child

Participant ,
Oct 30, 2015 Oct 30, 2015

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.

TOPICS
ActionScript
704
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Oct 30, 2015 Oct 30, 2015

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.

Translate
Enthusiast ,
Oct 30, 2015 Oct 30, 2015

- set the hit box visible to true and use alpha = 0 instead.

- hit test:

if(box1Name.hitTestObject(box2Name))

{

// run the damage function

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 30, 2015 Oct 30, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 30, 2015 Oct 30, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 02, 2015 Nov 02, 2015

Ok, that'll do it!

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 02, 2015 Nov 02, 2015
LATEST

You're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines