I made a game and when you die the score moves from top right to the middle of the screen using an animation. When you press Retry I reverse the animation by by setting the a speed parameter which is used as a speed multiplier in AnimationState.
While the parameter switches value (from 1.0 to -1.0 and or the other way around) the animation has a delay. I also noticed the longer you wait pressing retry, the longer it'll take for the animation to start. I do have to mention the animation doesn't have a transition to an idle state, so it probably means the animation time is moving > 1.0. I tried setting normalizedTime, but this didn't work either.
Does anyone know how to fix this?
Okay apparently I had to use ForceStateNormalizedTime() as normalizedTime was going above 1.0f and below 0.0f.
Related
In my game you need to fix things by pressing X. When X is pressed an animation of the guy fixing is played, then the text changes for the number of things left to fix, then the broken thing's game object is destroyed.
The issue I'm having is if the player spams X when fixing one thing it minuses the amount left enough to win the game without having to fix the other things (if that makes sense).
I have tried adding delays and stopping time, which haven't had the desired result.
I just had to change my fixhole bool to false!
I want to create jumping animation from 2 sprites and.
The animation can be illustrated like this
When his position is at the highest value, he changes state. Then keep that state until he falls off and changes to idle state.
I have done the research, watched tutorials on youtube, and I found something called blend tree. Then I went to the Unity documentation website and my mind was spinning around and around, I just couldn't understand it. And is there any way to know when his position is at the highest value? or any solution to animate him? And when to use blend tree
And also, a link to the tutorial
I would work with velocity conditions.
Let's say you start with an idle animation as default.
Then you make a transition from animation "idle" to animation "jumping" with the conditions IsGrounded = false to check if you're at the ground and velocityY > 0 to check if you're jumping or not.
Then do another transition from "jumping" to "landing" with the conditions IsGrounded = false and VelocityY < 0 so it checks if you're falling and will change the animation to the landing animation.
DESCRIPTION
I am learning to use Animation Layers. I created one with a mask so only the torso and head are affected. It has an empty state so that the animation isn't played first thing automatically, which transitions to a torso hit animation when a trigger is activated. The animation is set to Additive with weight of 1 as I want the the animation to be played with all of its intensity.
The animation works beautifully and when my character is shot in the torso it seemingly winces from the pain by bending its torso down while continuing to run or do stuff.
PROBLEM
After the animation is completed, the character remains with its torso bent down and continues running/doing stuff in that position instead of simply assuming the position of whichever animation is playing in the Base layer.
WHAT I TRIED
Fiddling with all of the settings visible in the image below, including "has exit time" and "interruption source", creating a transition back to the empty state and googling. Unfortunately, this is the full extent of my knowledge.
SETTINGS
QUESTION
How can I have the character revert back to the position of whichever animation is playing in the Base layer after the hit animation is played?
You don't have any transition back from Torso hit to New State.
Try adding one with
has exit time = true
exit time = 1
Like this (might want to adjust the duration of course)
(check image) Hi! I actually have two questions,
THE FIRST ONE: I have two flash animations that I want to play in front of the tank's turret whenever I shoot a bullet (I have different weapons with different fire delays, machine gun, bombs..) so how can I play that flash animation to work in with the fire delay of a gun ? (note that if I uncheck loop time, the animation stops in the last sprite + I don't know how to replay it).
SECOND QUESTION: I want simply to animate my turret when I shoot I just want it to go back a little and return, you know what I mean, only in unity, how, please?
give me just the idea of working and I'll do my research :) thank you!
I have tried to enable my animation when I shoot and uncheck the loop time, but the animation stops at the last animation sprite and I don't know how to replay it.
Using Unity's built in animator, I'm assuming you are using this, you need to have at least have 2 states, in your case Idle and Fire. You would then set the transitions of the animations to go from one another, Fire -> Idle and Idle -> Fire.
Within the Idle-> Fire you will need add a trigger due to it only happening once.
You may also need 2 SpriteRenderer Components to allow for the display of the Shot effect, just make a child GameObject with it and edit it in the Animation Window.
Triggers reset as soon as the transition has been made.
If you do not have a trigger go to the parameter tab and click the '+' button which will allow you to create a new trigger. Now that that is created, in your code whenever you want your tank / boat to fire just add. referenceToAnimator.SetTrigger ("triggerName");
Bringing up your delay you could always add an additional wait state that mirrors the idle state but only runs for the selected amount of time. Your new Animator would look like.
Idle -> Trigger -> Wait -> Fire -> Idle
I have a mediaElement. I change its speedratio according to my will 1x,2x,3x... It works the very first time but when I pause and play again it simply does not work. It starts playing in 1x speed. Is there anything I am missing?
I have encountered the same problem.
After some experimentation I found setting the SpeedRatio back to 1.0 before calling Play() again then waiting for the Position to change (typically using a timer) and setting SpeedRatio back to the old value seems to work.