- Home /
Animation AimUp & AimDown with the Mouse ?
help a beginner of a fps ....
why only 1 animation works =?
function Start()
{
// First set both animations layer value to something different to each other. This allows you to play them both at the same time.
animation["aim"].layer = 1;
animation["dodge"].layer = 2;
// Second set both their speed to 0.
animation["aim"].speed = 0;
animation["dodge"].speed = 0;
// Thirdly play both the animations
animation.Play("aim");
animation.Play("dodge");
}
// Use the mouse input to set the normalized time of the animations to what you want. Something like this.
var maxMouse : float = 366;
function Update()
{
var newTimeAim : float = Mathf.Min(maxMouse, Mathf.Max(0, Input.mousePosition.y)) / maxMouse;
var newTimDodge : float = Mathf.Min(maxMouse, Mathf.Max(0, Input.mousePosition.x)) / maxMouse;
animation["aim"].normalizedTime = newTimeAim ;
animation["dodge"].normalizedTime = newTimDodge ;
}
Answer by TonyLi · Apr 29, 2013 at 03:13 PM
It looks like you're trying to use additive animation with the legacy animation system.
Two points:
Additive animations are based off of a non-additive animation, such as an idle or run cycle. You need to add a non-additive animation.
You need to set the blend mode to additive. (Set the animation state's blendMode to AnimationBlendMode.Additive)
For more info:
http://docs.unity3d.com/Documentation/Manual/AnimationScripting40.html#Additive
Your answer
![](https://koobas.hobune.stream/wayback/20220613101208im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
orbit mouse camera animation movement script 1 Answer
Help with mouse and keyboard movement. 0 Answers
Animation play when dead 2 Answers
Can I make animations snap to a frame? 1 Answer
my animation script does not work 0 Answers