- Home /
How to script an animation/animator to stop mid animation, toggle play direction and potentially transition change object on raycast hit?
Hello everyone
I am hoping to get some insight from the lovely people of this community on how to script animation or animators to get the desired effect I am looking for.
I am trying to work on my final major project for university and was trying to make it so that the player can shoot certain objects in the environment with an ageing ray. I thought that the best way to do this effect is by having an animation attached to the objects that need to change and trigger them with a raycast.
It would age them in one direction when first hit but then back in the other when hit again. It would be a ray that would need to be kept held down to complete the transition from old to new or new to old.
Sorry if this just sounds like me asking for someone to script it for me but I mainly am hoping for guidance and maybe some example script work so that I can understand what I can do. I had given it a try myself looking into animations and animators getting as far as making it run the animations but couldn't get it to stop and start from the current frame that it was left on.
Any help with this would be much appreciated.
Your answer
![](https://koobas.hobune.stream/wayback/20220612171612im_/https://answers.unity.com/themes/thub/images/avi.jpg)