How do I change a 3D box collider during an animation?

Solved
ZehraB Posts 3 Registration date Thursday May 2, 2024 Status Member Last seen June 7, 2024 - Updated on May 10, 2024 at 03:39 PM
BoBot Posts 301 Registration date Wednesday October 11, 2023 Status Moderator Last seen November 19, 2024   - Jun 7, 2024 at 07:05 AM

I don't know any good ways of changing the box collider for my character during its jump animation and after doing some research, I decided to use the Animation Window. It took forever to even access the animation from the drop down because it was Read Only.

But now that I've gotten to it and figured out how to add the box collider size and center as a property to edit during the animation, it won't work. I want to edit the collider through the values in the Animation Window by also looking at the animation in the Scene view, but every time I press play in the Animation Window, I get a ton of errors saying "NullReferenceException: The Playable Output is null." I feel like wanting to change the collider size during an animation shouldn't be too hard because it doesn't sound that hard. But just getting to this point has been nothing short of ridiculous, and I'd be lying if I said I wasn't getting frustrated.

I can't find a single resource online showing how to edit a 3D box collider to change in size during an animation.
Can anyone help!

1 response

BoBot Posts 301 Registration date Wednesday October 11, 2023 Status Moderator Last seen November 19, 2024   10
Jun 7, 2024 at 07:05 AM
Hello !
The AI who loves a challenge is here!
You're probably running into issues because you're trying to directly animate the BoxCollider. That's not what you're supposed to be doing. Animating a BoxCollider is complex and not recommended as it could introduce unnecessary problems and complications.

Here's a better method. You need two BoxColliders, one for the normal state and another for the jump state. When the jump animation starts, you disable the first collider and enable the second. This way you're not animating Collider properties, just enabling and disabling GameObjects.

To do this:

1. Place two BoxColliders on your object. Set them up how you want them for each state.
2. At the start of the animation disable the normal BoxCollider and enable the jump BoxCollider.
3. And then, when the jump animation ends, do the opposite.

On the subject of the errors, the "NullReferenceException: The Playable Output is null" error is probably due to you having tracks or clips on your timeline that don't have outputs. Check your timeline to make sure every track and clip has an output. The output specifies where the track's animation data is applied.

Hope this helps and fixes your issue.

1
ZehraB Posts 3 Registration date Thursday May 2, 2024 Status Member Last seen June 7, 2024
Jun 7, 2024 at 04:00 AM

Thanx issue resolved!

0