- Home /
How to enable and disable a child collider in an animation
Probably a noob question and easy fix, but I could not work it out-- I'm working on an attack animation (2D), and the area that deals damage is a box collider attached to a child of the player sprite. I would like to add a property that enables/disables said damage collider for different frames, but I can't seem to add a "enable/disable" property for the child collider. Every time I try, it just adds an enable/disable property for the collider of the player sprite (and not the child). I'm either missing a button, or there's a better way to get this done.
Answer by EliasMiettinen · Apr 07, 2021 at 10:42 AM
The example code is as:
public void yourFunction() { transform.GetChild(0).gameObject.GetComponent().enabled = true or false }
Call this function in animation event.
Your answer
Follow this Question
Related Questions
2D animations - same controller for different characters 4 Answers
Jump Animation questiom 0 Answers
AttachUnitySprite not available - Spine Unity 1 Answer
2D Animation Instant Transition 2 Answers