HELP! Need a simple (Play Animation Clip on Trigger Enter)

Hello guys… I’ve been struggling for 2 days and can’t seem to find a simple (Play Animation on trigger enter, if tag. == “Player”.) I also need the script to play it one shot. I know I can edit the animation clip to NOT Loop. If thats all I have to do, then the script can simply be play animation on trigger enter if tag. = Player.
Please I need help on this asap!

Bonus: If you guys could figure out a better script that allows me to use it on everything without having to make copies of it that would be fantastic. It would be a script that allows me to add it to any object and simply plug in the animation clip on a slot for it to play upon trigger enter.

Note: Please don’t suggest a script that deals with the “Animator”. I already have one and its a nightmare. Cause I have an animator and I added parameters to every animation within and it just doesn’t play right.

New NOTE: The animations are placed on each individual object and are marked as “Legacy”.

Not sure you can get around learning the Animator if you want to use animations. I am pretty sure you need to have your animation as one of the possible states in the animator to play it. I would suggest watching basic tutorials for the animator. Playing the Animation on trigger enter should then be the easy part.

something like this, but I am not sure how your actual functionality should be/ what things collide and stuff…

private void OnTriggerEnter(Collider other) {
other.GetComponent<Animator>().SetInt("state",1);
}

Hello, and thank you for your response.
That script won’t work for me. I already have a script similar to that, which calls for the Animator.
I am looking for a script that calls directly for an animation clip from an object that has an animation (not an animator).

I am very familiar with Animations and Animators. I’m just not savvy with scripting. Calling animations from the Animator where the animations are stored and connected doesn’t work for me cause once it triggers the first animation, that animation, makes other trigger colliders move and such. And all of that just doesn’t work by calling it from the animator.

I don’t exactly know what you mean with the animation moving trigger colliders, and why that changes anything about using the animator.
Anyway, as I understand it, the only option for you to play animations without using an animator is using playables. (There are plugins that do similar things I think, like Animancer) I am not very familiar with playables. Check out this forum post , the poster also wanted to play animationclips without an Animator.

2 Likes

Hey, thank you again for all your help! Means a lot. I have solved the issue.