- Home /
Newbie trying to make a crushing ceiling type of hazard. Need to enable and disable Colliders depending on frame of animation I think
As the title says, I'm trying to make a crushing ceiling. Here's a little animation for reference
I looked into this a little bit but nothing has quite made sense and one thing I found linked to AnimationEvents in the Manual but it says it's no longer there. I have no idea if that's because it's removed or because I only have the free version of Unity right now (Don't really have the money for it right now)
I have two immediate guesses on what I might need to do
1) Disabling and enabling Colliders on certain frames of the animation but I'm not sure how to do that or if it's still possible in a simple way
2)I have the passive state(when it's up) and the active state (when it's down) as two objects and just sorta switch between them on a timer in a sorta manual-animation style
I'm not entirely sure on how to do this and I don't want to just mindlessly throw my head against a wall today trying to figure it out. If anyone could steer me in the right direction that would be much appreciated. Thanks in advance for any help you can give!
Answer by LeFlop2001 · Jun 19, 2020 at 12:53 PM
im not sure why you want to enable and diable collider but doing so using an animation can either be done by enableling automatic keyframing in the animationtab and en/disableling the collider manuely or by using an animation event that calls a function that messes with the collider
The Enabling and Disabling of colliders is so that when it's down you can't pass through the sides to ignore the hazard and so you don't just die from skim$$anonymous$$g its side when it's down and harmless. Also it'd be to make sure there's not just a death box sitting in the empty space when it's up. That's why I figured I might need to disable and enable colliders
@oshawot123 Im pretty youre already have a raycast in place to deter$$anonymous$$ wether the player is grounded or not, if thats the case you can simply use a boxcast (or raycast) ,slightly below the crushing ceiling ,with the grounded bool as a secondary condition to kill the player.
no disableling of colliders needed
Uh... something tells me a transform gamobject checker doesn't count. I also get the feeling I might need to re-do some things
@oshawot123 what do you mean by checker doesnt count. Do you still need help or na?