Playing Animation on Trigger in Unity
In this Unity Tutorial, I show you how to animate an object, setup the animation controller, write the C# script and be able to play an animation on a trigger event, as well as stopping it when you exit. Suitable for Unity 5 / 2017 / 2018 and above!
➡️Playing Animation on Trigger (With one line of code): • Play ANIMATIONS - ONE ...
🎁 Get OVER 160+ Scripts, Projects and premium content on my PATREON HERE:
➡️bit.ly/SpeedTutorPatreon
·························································································
🔥 INSANE UNITY SAVINGS: bit.ly/UnitySalesHub
🕹️Synty Publisher Mega Sale: bit.ly/SyntyPublisherMegaSale
🕹️SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
🕹️Unity WELCOME2022 Offer: bit.ly/UnityWelcome2022OFFER
🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
🕹️Humble Tutorial Bundle: bit.ly/MammothUnityTutorialsB...
🕹️Unity ART Bundle: bit.ly/UnityHumbleArtBundle
🕹️Unity TOOLS Bundle: bit.ly/UnityInsaneToolsBundle
🕹️SFX for Games Bundle: bit.ly/SFX-Music-For-Games
🕹️Learn Programming Games Bundle: bit.ly/LearnProgrammingGames
🔥Unity Materials / Files & More:
🕹️CGAxis 400 PBR Material Bundle: bit.ly/CGAxisPBRDeals
🕹️Synty Assets: bit.ly/SyntyLowPolyAssets
🕹️Filebase Assets: filebase.gamedevhq.com/ (Code: SPEEDTUTOR2022 - Sign up for a FREE MONTH)
🔥 UNITY SUBSCRIPTIONS:
🕹️Unity Plus: bit.ly/UnityPlusDeals
🕹️Unity Pro: bit.ly/UnityProDeals
·························································································
💰BIG DISCOUNTS on my website, for my UNITY ASSETS:
➡️www.speed-tutor.com
💬Join the Community Discord:
➡️ / discord
💝 Make a donation to the channel:
➡️www.paypal.me/speedtutor
·························································································
⬇️ SpeedTutor Puzzle Assets:
➡️Unity Store: bit.ly/STUnityStorePuzzlePacks
➡️My Website Discounts: www.speed-tutor.com/
⬇️ SpeedTutor Best Selling Assets:
🧩Adventure Puzzle Kit: bit.ly/STAdventurePuzzleKit
🗒️ Note & Letter System: bit.ly/STNoteLetterSystem
🔍Examine System: bit.ly/STExamineSystem
🔢Keypad System: bit.ly/STKeypadSystem
⬇️SpeedTutor Model Packs:
➡️Unity Store: bit.ly/STUnityStoreModelPacks
➡️My Website Discounts: www.speed-tutor.com/
My Assets include: Gas Mask, Flashlight, Generator, Themed Key , Padlock, Phone, Chess Puzzle, Lever, Valve Puzzle, Fuse Box & Safe Systems. Cardboard, Debris, Massive Models and more!
························································································
⭐ Connect with me:
💬| Discord: / discord
🐦| Twitter: / speedtutor
📱 | Facebook: / speedtutoruk
🖥 | Website: www.speed-tutor.com
·······················································································
#SpeedTutor #Unity #Animation
Пікірлер: 303
Don't trigger me or I'll throw animation at you! ;) 🔥UNITY SAVINGS: bit.ly/UnitySalesHub 🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks 🔥HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
@turnersaint7956
3 жыл бұрын
a trick : watch series at Flixzone. Been using them for watching a lot of movies these days.
@waynebodhi9617
3 жыл бұрын
@Turner Saint Definitely, been using Flixzone for years myself :D
@thaddeusazariah5568
3 жыл бұрын
@Turner Saint yup, have been watching on Flixzone for years myself =)
Tip: If you want your transitions to happen without a delay, uncheck "Has Exit Time" while you have your transition selected in the animator.
@SpeedTutor
2 жыл бұрын
That's a heroic tip, thanks for sharing my friend! :D
You are a godsend man. I'm up here for at 1am trying to figure this out for hours for a class demonstration the next morning and I can't thank you enough. Finally works!
@SpeedTutor
3 жыл бұрын
I do have another animation tutorial which can make this happen in a line of code which might also help you! :)
@namdol_
3 жыл бұрын
@@SpeedTutor Awesome! Will give it a watch.
Do everything as he says exactly and you won't hate yourself
God you need way more views. This is simple and very dynamic within a game. Thanks!!
@SpeedTutor
5 жыл бұрын
No problem at all! :)
This also works in 2D! I tried this tutorial and at first I struggled a lot because nothing happened and I didn't know what I had done wrong. Then I realized if you are using 2D Colliders etc. you need to change one line of code to make it work: private void OnTriggerEnter2D(Collider2D other)
@SpeedTutor
3 жыл бұрын
You're exactly right! :) I do also have a couple of recent tutorials where I show you how to do this in an even easier way! :)
Playing Animation on Trigger (With one line of code): kzread.info/dash/bejne/naV2qclvgtDLYZM.html&
Thank you so much for this, this is the first tut that i've found that works with my set up.
@SpeedTutor
5 жыл бұрын
Great to hear it, thanks for watching! :)
Thank you so much!! i found this tutorial after two days of trying to make a working elevator and it made it work!!
@SpeedTutor
4 жыл бұрын
Glad I could help!
I even duplicated this script as "PlayMyAnimation2" and input my 2nd animation but it does nothing, is it trying to call from the same animator controller?
Great tutorial and saved me lots of time researching about animation controllers but I ran through an error for my game. It finishes the animation and only then starts the new animation when my parameter is set to true. Can you cut the animation immediately and start the new one as soon as the bool is set to true? Please help.
Awsome to see you back with tutorial :D so this is the mecanic to activate animation state/StateMachine :)
@SpeedTutor
5 жыл бұрын
Thanks man! Good to hear from you again! :)
@StigDesign
5 жыл бұрын
@@SpeedTutor thank you:D
Thank you, God bless you.
OMG Thanks! I have been trying to figure this out for so long!
@SpeedTutor
3 жыл бұрын
Glad I could help! :)
Hi! My iOS app is locking the phone’s screen after 1 minute without clicking on the screen. I started with Unity recently and I’m not a programmer at all. Do you know what I need to do? Thanks!
Nice, could find several uses for this little gem :)
@SpeedTutor
5 жыл бұрын
Great to hear it, thanks for watching! :)
I would love seeing a animation tutorial ive tried to get into it but every time i do i struggle with learning how to animate stuff.
@SpeedTutor
5 жыл бұрын
What sort of things do you struggle to animate?
You're a life saver man, thanks a lot
@SpeedTutor
4 жыл бұрын
No problem at all, glad I could help! :)
Thank you for this tutorial man!
@SpeedTutor
4 жыл бұрын
No worries at all! :)
Increadibly healpful. Thank you!
@SpeedTutor
2 жыл бұрын
That's no worries! Thanks for coming along to watch my friend! :)
Thank you for this tutorial!
@SpeedTutor
3 жыл бұрын
You are very welcome!
very good tutorial hope your channel gets big like brackeys keep making tutorials like this
@SpeedTutor
4 жыл бұрын
Thanks very much! :)
Nice tutorial bro but i still don't know how to make obj fell when player enter trigger please reply
great tutorial! thank you very much
@SpeedTutor
4 жыл бұрын
No problem at all, thanks for watching! :)
For example what if I want to trigger 10 vens on one trigger. How do I do that?
Thanks after 1 day of research finally found a good toutorial
@SpeedTutor
2 жыл бұрын
I'm glad you found this, thanks for watching! :D
plz man tell me bro haw can i just make a ui button witch rotate my car backward and forward
Works great, thank you!
@SpeedTutor
3 жыл бұрын
You're welcome!
Good job! Thanks ...
Gracias hermano saludos desde México
Man! You are a legend! Thank you very much!
@SpeedTutor
3 жыл бұрын
You're very welcome!
@SpeedTutor How can i do this on click?
i want to implement it on a moving a character
Hi, I am doing that player trigger the bomb, then explosion animation occur, the concept is same with this ?
@SpeedTutor
4 жыл бұрын
Absolutely! :)
how would i get the animation to lock in place when it finishes its animation? I'm trying to make a sliding door.
@csrikanth0007
3 жыл бұрын
set the desired final state of obj in another state and keep it as the last one in your animator
Thanks man , I love you
@SpeedTutor
4 жыл бұрын
No worries, thanks for watching! :)
Thanks Worth it bro :) thanks for explaining this simple
@SpeedTutor
2 жыл бұрын
I'm really glad you think so, thanks for coming along to check this out! :D
wow thx! you teached me how to use unity animations fully!
@SpeedTutor
Жыл бұрын
Glad to hear that!
OHHHH god thanks you mann !! love you !
@SpeedTutor
3 жыл бұрын
I'm glad it helped you out! :)
Hi! Great tutorial, I have been using it a lot in my game. How do you make the animation only play once when you enter the trigger?
@SpeedTutor
Жыл бұрын
You can also check out my newer tutorials on this, which may help you out even easier! :)
Hey great video! I based my animation off this video but Instead of the player being the trigger on an object, the object is a trigger on the player. When the object hits the player it is destroyed and the bool stays true, i tried using an else statement to keep it false otherwise, but it seems the object being destroyed on the player is keeping the bool to true. Any ideas on how to fix that?
@SpeedTutor
4 жыл бұрын
When you destroy the trigger, make sure you to turn the bool to false!
Many thanks m8 u helped me A LOT !!!
@SpeedTutor
2 жыл бұрын
I'm glad you think so! I also have an updated tutorial which may help you out too! :) It's in the description.
Is there some way to make this work with a Raycast? I want to have my player look at an object, press E, and then an animation plays. However, doing the method in this tutorial doesn't seem to work and I don't know why... The raycast works, I have a debug. log telling me that. It's just that the bool is not changing to true for some reason
@RespectTheNerd
4 жыл бұрын
Have a similar problem with an animation that's supposed to activate on a button press, you don't happen to have solved it yet? Would love to see the solution.
thank you so much this was really helpfull
@SpeedTutor
Жыл бұрын
You're very welcome, I even have an even easier tutorial on playing animations in the description! :)
Any way to use multiple events through this one script? Using it for elevator doors, got the first floor working, and dont know how to go about adding a second animation with its own new trigger for the second or third floor.
@SpeedTutor
4 жыл бұрын
Why not add two to the same script?
Thanks bro, Really appreciate it.
@SpeedTutor
2 жыл бұрын
That's no problem at all! :)
does this also work with just a collider or do you need to have a cube showing
@SpeedTutor
4 жыл бұрын
Just with a collider!
I can't get the animation to quit when I leave the box that has the trigger
Hi, if animation tag.target get destroyed? animation stuck and play forever, what i should type to make animation stop when tag.target get destroyed?
@SpeedTutor
3 жыл бұрын
I'm not really sure as this isn't something I've looked into before :(
How can i get this to play sound along with an animation cus im wanting to make a horror game based on 21 years of reoccurring nightmares which is about up until a year ago im 22 now and turning 23 on the third of October
@SpeedTutor
5 жыл бұрын
Just activate tehesong when the animation starts?
Omg, thank you so much.
@SpeedTutor
3 жыл бұрын
No problem at all! :)
Thank you so much dude ❤
@SpeedTutor
Жыл бұрын
You're welcome!
It work very well on my zombie animation thank you
@SpeedTutor
Жыл бұрын
Great to hear it! :D
I have a problem, for some reason my animator doesnt do the transition when i want it to (player needs to click the left mouse button to initialise) the parameter is completed so the condition becomes true but nothing happens within the animator, i am using the mouse button down version of it, any solutions, would mean a lot and thank you!
@SpeedTutor
2 жыл бұрын
You could take a look at the newer animation video I've created in a the description and/or pinned comment. I should you how to do it in an even easier way. It might help! :)
5:15 when I press the + button it doesn't show any layer types, it just adds a layer. what should I do?
@MoreNimrod
3 жыл бұрын
You need to click on the Parameters tab, not the Layers tab. You're adding a bool as a Parameter and not as a Layer.
i tried to do the script in 2d and i got this errore Assets\Playeranimation.cs(13,35): error CS1061: 'Animator' does not contain a definition for 'Setbool' and no accessible extension method 'Setbool' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?)
@SpeedTutor
2 жыл бұрын
I have a different tutorial which will show you how to create an animation and play it in code, easier than this one. I think I've linked it in the video description! :)
This would be good for traps..quick question..instead of a player walking into the trigger can a object be used? ( a rock on a floor tile for example )
@SpeedTutor
5 жыл бұрын
Yes, in exactly the same way. As long as one of the objects has a rigidbody, you could do it in exactly the same way! :)
It worked, but suddenly it stopped working and Idk why
I need help, on the editor the animation works fine but on build the animation doesn't work.
@SpeedTutor
5 жыл бұрын
That's strange, has anyone reported this issue online?
Thank you, you hero and saint of a man
@SpeedTutor
2 жыл бұрын
I am glad to be of service to you my friend! :D
I did this and it works but the animation doesn't play at the speed I have it set to. Basically I have a player interact with a switch to lower lava on the ground. When the player interacts with the switch the lava instantly disappears, when in the animation it was slowly going down. Is there a way to have it not be instant?
@SpeedTutor
Жыл бұрын
I'm not really sure about that one, can you purposely slow the animation down?
Just a curiosity in the script: Why did you use [SerializeField] and private, instead of a public variable? :)
@SpeedTutor
4 жыл бұрын
It makes private variables visible in the inspector. It's good to keep variables private UNLESS they actually need to be public (Across other scripts) :) - I hope that helps!
Hi! I just found your channel and I'm impressed! I have a question if you don't mind, that is, does this work if I only want my animation to trigger once? ( for etc. Book falling from bookshelves by itself) Thanks and keep making good content! :)
@SpeedTutor
4 жыл бұрын
Yes of course! :)
@xueniyu8187
4 жыл бұрын
@@SpeedTutor That's great to know, I'll try it out then! Thanks for the reply too! I am a beginner so your channel is a really big help! One of the best out there ~ (I mean it)
@SpeedTutor
4 жыл бұрын
Thanks very much! :) I really appreciate it!
Thank you so much! I was using to stop trigger with else but now realized I d had to exit :)
@SpeedTutor
3 жыл бұрын
Glad I could help! I do have another tutorial on playing animations on trigger, which is easier and more recent! :)
@acikgozemre
3 жыл бұрын
@@SpeedTutor Thank you i will watch it
There seems to be a slight delay after you enter the collider and before the animation starts. What's the reason for that? Or am I just not seeing it correctly?
@Goggalor1990
3 жыл бұрын
I don't know if you ever figured it out, but if you did please let me know lol. It does have a slight delay, not sure of the reasoning.
@KeiNovak
3 жыл бұрын
@@Goggalor1990 Sorry, It's been so long so I don't remember. Looking at the video again though, it seems like it may be the animator controller. IIRC, it does some auto-blend thing for blending between animations... in this case it may just be blending from a Stop "animation" to the actual Spinning animation... hence the weird spin-up time and spin-down. Let me know if that helps.
thank you so much bro
@SpeedTutor
2 жыл бұрын
No problem at all! :D
Did the scripting part change, it doesn't autofill like your video..
@SpeedTutor
Жыл бұрын
Does the autofill work for you, nromally?
I am unable to drag and drop my animation controller into my script component. Do why this could be?
@SpeedTutor
Жыл бұрын
Any errors?
Hi, thanks for the tutorial. I have a problem with the MyAnimationController variable, though. I am using an array of prefabs as collision triggers, if I set the component that MyAnimationController asks through the inspector (as seen at 8:20) on those prefabs (I am assigning it "Avatar", as my Avatar is my player and it's the GameObject on which I want to change the animation on trigger collider with the prefabs), even if I hit "apply all" in the inspector, after I delete the prefabs from the hierarchy (as I only leave their spawner) and I start the game I get this error: " UnassignedReferenceException: The variable MyAnimationController of playMyAnimation has not been assigned. You probably need to assign the MyAnimationController variable of the playMyAnimation script in the inspector. UnityEngine.Animator.SetBool (System.String name, System.Boolean value) (at /Users/builduser/buildslave/unity/build/Runtime/Animation/ScriptBindings/Animator.bindings.cs:343) playMyAnimation.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/playMyAnimation.cs:13)" And if I reimport the prefabs on the hierarchy from the assets, the component "Avatar" which I assigned to MyAnimationController disappears. Any idea about how to solve this?
@SpeedTutor
4 жыл бұрын
The connections are sometimes lost when you use prefabs, you could always search for the controller manually when you want inside those scripts. I'm not sure if that's helpful or not?
@breaola2470
4 жыл бұрын
@@SpeedTutor I hope it is, I'm still not confident in C# and unity to try what you suggest, but today I'll try to work with scriptable objects instead of prefabs to see if something changes. Thanks buddy!
What does the Code [SerializeField] do? Why did you use it?
@SpeedTutor
5 жыл бұрын
It makes a private variable visible in the inspector, so we don't have to have everything public.
I want to trigger a death animation on hitting an obstacle in my endless running game, will you please help
@SpeedTutor
2 жыл бұрын
I have a new tutorial about this, which might help! :) Its in the description.
Dear Speed Tutor, In my scene I got my FPS Character Controller (the player) and my Zombie following the FPS Character Controller with script, and I added a attack trigger so when the FPS Character Controller gets close the zombie attacks the FPS Character Controller at 4.0 Stopping Distance. So all I need to do is the health bar goes down when the zombie attacks the FPS Character Controller, does anyone know any tutorials that show the C# Visual Studio code or in Bolt Visual Scripting to make the health bar go down when the zombie attacks the FPS Character Controller? Or can anyone walk me through it on Unity 3D? I cannot find any KZread tutorials on a health bar going down when a enemy attacks the FPS Character Controller, in the tutorial they just talk about the health bar going down when the space bar is pressed, or the health bar changing color's as it goes down. Can you make this KZread tutorial for me, I am sure it will help lots of other people with making their video games? So do I need to make a script for the health bar, and the zombie attack only, and the FPS Character Controller (the player) is not included in script of the health bar going down when the zombie attacks my player? So its just zombie, and health bar that is needed when you write a script for a health bar to go down?
I got a problem with [SerializedField] it tells me i have nothing referenced or something like that. My Code is the same except for the Names, it doesn‘t highlight the code line for the Animator… what am i doing wrong?
@SpeedTutor
7 ай бұрын
It needs to be [SerializeField] without the "D" :)
Works great!!!! I set up 3 colliders with different names to play different animations but when my player collides with the first one it plays all my animations one after the other.I wanted it to play different animations on different colliders positions.:(
@SpeedTutor
2 жыл бұрын
That shouldn't happen, but I do have a tutorial which is updated from this. It's in the description which might help you! :)
Again one great tutorial from you [great tutorial = understandable+quick+straight to the point]. Thank you. But I am wondering is it possible to make something like universal script to start anim? What I actually mean is, {bare in mind im totally noob in scripting} instead of -private- thing can we have it -public-? So to use one script for different objects and different animations? Just, you know, there is that Door what have to be open, so I will just drop that script on the door and than drop already made animation from previous door and maybe this door will open not by "player" but by some "rigid body tagged: ball" which I will just drop from the scene in to the specific field in the script in Unity properties panel. I hope you you see what I mean :)
@SpeedTutor
5 жыл бұрын
I know exactly what you mean, you could just prefab your door which has the script on it and duplicate that same thing. So it's almost like two copies of the same thing but they would work independantly! :)
underrated channel
@SpeedTutor
4 жыл бұрын
Thanks man! :)
Good job. You can also turn off the mesh renderer to give the player the illusion of it being automatic.
Very Useful tutorial, short simple and yet very very useful
Thank you, works like a charm! Although I have a question, is it normal for it to have a delay before playing the animation? I noticed it took like about .5 seconds when you step in the trigger box. I tried for an animation for my door and it also has a delay too. Is there anyway to control it or Unity is doing something in the background?
@SpeedTutor
4 жыл бұрын
I do also have another tutorial on playing animation which might also be helpful for you! kzread.info/dash/bejne/nZqMttx6kZytZMo.html
@mustachebutter
4 жыл бұрын
@@SpeedTutor thanks a lot, this is perferct.
@SpeedTutor
4 жыл бұрын
Great to hear it! :)
@rocketpadmedia4918
4 жыл бұрын
You could also try changing the 'speed' on your DefaultState to something like 10 so it cycles through faster and reduces the delay getting to the next animation event.
Could you do a door tutorial?
@SpeedTutor
5 жыл бұрын
I'll see what I can do! :)
Thank you very much, it is really useful. I was thinking of making an animation on my channel and it may help me.😬
@SpeedTutor
11 ай бұрын
Great to hear it, my friend. Good luck! :D
does should work with unity 2017 ? or specific to 2018 ? can you do one with timeline
@SpeedTutor
5 жыл бұрын
It would easily work with Unity 5 / 2017 / 2018 and onwards.
@TheBlackbirdii
5 жыл бұрын
@@SpeedTutor off topic any chance to make a tutorial how to add rumble when player get hit or enter a trigger ?
Thanks so much. I was about to quit. New sub!!
@SpeedTutor
5 ай бұрын
Haha! You're very welcome, I'm glad you didn't quit. What are you creating?
Hey, I'm making a game right now that requires a lot of animations that need to be played when entering a trigger, and I mean A LOT when I say a lot. Wouldn't doing this way require me to make a script and animator set up for every single animation I need triggered? If so, is it still possible to do it other ways that will save me the time?
@SpeedTutor
3 жыл бұрын
I do have another animation tutorial which you could just call the name of your animation, on the trigger event without this setup! It's on my channel! Just search "Animation".
@Snikabarz
3 жыл бұрын
@@SpeedTutor dude that just saved my life, thanks. That should speed up the developing process quite a bit
@SpeedTutor
3 жыл бұрын
I'm happy to hear it! :) You watched the older one?
@golflefleur2767
3 жыл бұрын
@@Snikabarz which video was it? i really need it!!!
Awesome ❤❤
@SpeedTutor
8 ай бұрын
Thanks for watching, how did you find me?
Great tutorial, well done. If I am using an arcamera to trigger would I need to change "player" to "arcamera" in the script?
@SpeedTutor
3 жыл бұрын
No, no - You can keep it as player! :)
@davidmiller6452
3 жыл бұрын
@@SpeedTutor even though my ar camera is labeled "Maincamera"
@davidmiller6452
3 жыл бұрын
I would be triggering with the ar camera
@davidmiller6452
3 жыл бұрын
@@SpeedTutor do you have a tutorial for adding sound as an event in the annimation?
I have a question: I want to set up a barrier/trigger, so when the player enters it, it makes them turn around and walk away from it (not allowing them to continue in the same direction) would this work for that?
@SpeedTutor
4 жыл бұрын
That's a good question, it may work but you'd likely want to put your player on a path which they follow to the point you want to send them back too. Lets say for example, taking input controls away from your players and then translating the character position somewhere else!
@CraftyMaelyss
4 жыл бұрын
@@SpeedTutor I tried that but ran into a problem, for some reason once the animation is done, it cancels out gravity P: Do you know how to make the animation work so that it doesn't tamper in gravity? (So it works same as normal once the animation is over?)
@SpeedTutor
4 жыл бұрын
I'd probably say that you don't use an animation to take control of your player, just move your player away manually. Are you doing a 3D game? Third person on Third person?
@CraftyMaelyss
4 жыл бұрын
@@SpeedTutor Yes, I'm doing a 3D game, however this part of the game is in 1st person but still has a model, so the arms and hair are visible. How would I stop the animation from disabling the gravity on the model though? Is there an option for gravity to always be applied to the model, even during animations? Also thank you so much for the fast response too! This is my first game but still a big project and I'm pretty determined to make it the best I can :)
@SpeedTutor
4 жыл бұрын
Rather than doing this, could you just enabled a new camera which moves instead of your players? Then give control back to the original player?
Hm for some reason it doesn't like this part: [SerializeField] private Animator myAnimationController; it seams not knowing [SerializeField]. What is wrong?
@SpeedTutor
Жыл бұрын
Is there an error before or after that?
good tutorial again my friend!
@SpeedTutor
Жыл бұрын
Thanks man, I even have another tutorial which helps you do this in an even easier way. It's in the description of this video :)
@gmangman123
Жыл бұрын
@@SpeedTutor take look my demo! kzread.info/dash/bejne/Z4ZhxraImNqnnpc.html
PERFECT
@SpeedTutor
4 жыл бұрын
Great to hear it, thanks for watching! :)
thank you so much bro love you from india
@SpeedTutor
2 жыл бұрын
You're very welcome, my friend! :)
Thanks
@SpeedTutor
3 жыл бұрын
You're very welcome! :)
Did I write something wrong? My code is just straight up not working. There are no errors or warnings when launching the game. I can't see if I wrote something wrong, please help. public class Test : MonoBehaviour { [SerializeField] public Animator myAnimationController; private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { myAnimationController.SetBool("playerNear", true); } else { myAnimationController.SetBool("playerNear", false); } } }
@SpeedTutor
3 жыл бұрын
Do you have any errors?
thanks
@SpeedTutor
3 жыл бұрын
You're very welcome! :)
Great
It is working, thanks! But what if I don't want the animation to be a loop?
@SpeedTutor
4 жыл бұрын
You can select the animation itself and untick "LoopTime" I think!
@elbladel
4 жыл бұрын
@@SpeedTutor It worked! Thank you so much!!!
@SpeedTutor
4 жыл бұрын
Haha, no worries at all! :)
You forgot something... when i clic on conditions, it says "Parameter does not exist in Controller".... so ?
When I place the object in the Animator space in inspector and I play the button to play the game, the space gets empty again. I dont know why does it happen... please help me
@SpeedTutor
4 жыл бұрын
I'm not sure, any errors?
@TheAlvar0x
4 жыл бұрын
@@SpeedTutor the problem was that I put "anim = GetComponent();" when it resets the Animator component when play the game. i've fixed it
i cant thank you enough
@SpeedTutor
4 жыл бұрын
I'm glad to hear it! :)
script class cannot be found.. I guess there's no easy way around this.. Also even with the default state set as entry, the animation still plays...
@SpeedTutor
2 жыл бұрын
Is the script name the same as your class name?