UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


Walking Animation Script(Help)

power_settings_newLogin to reply
+12
gggsss
DeveloperLuke
tanay2003
asihall
Noahfoah
FainterStreaker
DARTHVADEREX
daniel202gaming
yashtewarisaab
developer23
MisterNinjaBoy
Espon17
16 posters

descriptionWalking Animation Script(Help) EmptyWalking Animation Script(Help)

more_horiz
I have just created the walking animation script and have made it a child of the gun M4A3. I have made the key(w) which will start the animation, but when i click play the animation is already going and does not stop and it does it even if i don't press "w".
Thanks, i can post script etc...
This is in relation to video 3 of the FPS Tutorial.

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
Make a new script, and use this to stop animations. Attach this script to you're gun.

Code:


    function Update()
{
 if(Input.GetKeyUp("w"))
 {
  // Plays the _____ animation - stops all other animations
  animation.CrossFade("idle");
 }
}

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
I use this Script created by me Very Happy:


FIRST SCRIPT (PLAY ANIMATION):  

Code:

var AnimationClip : AnimationClip ;
function Update() {

if (Input.GetKeyDown (KeyCode.W))
{
    animation.Play();
 
}

}





SECOND SCRIPT (STOP ANIMATION):

Code:

var AnimationClip : AnimationClip ;
function Update() {

 if (Input.GetKeyUp (KeyCode.W))
{
    animation.Stop();
 
}

}


Last edited by developer23 on Thu Jun 05, 2014 9:06 am; edited 1 time in total

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
It essentially does the same thing. Also developer 23, I reccomend you use animation.crossfade insdead of animation.play.

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
MisterNinjaBoy wrote:
It essentially does the same thing. Also developer 23, I reccomend you use animation.crossfade insdead of animation.play.
Thanks a lot Very Happy

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
Hello masterninjaboy, I'm new here and I love your videos!

Instead of the your gun models, I tried animating a simple cuboid with all the other steps done exactly the same. The script is exactly the same too, but the animation keeps running as long as the 'Animator' is a child of the Cuboid, and then doesn't work at all when I remove the 'Animator'. I tried many things with my scripts, nothing works

descriptionWalking Animation Script(Help) EmptyD:

more_horiz
MisterNinjaBoy wrote:
Make a new script, and use this to stop animations. Attach this script to you're gun.

Code:


     function Update()
{
 if(Input.GetKeyUp("w"))
 {
  // Plays the _____ animation - stops all other animations
  animation.CrossFade("idle");
 }
}



Whenever I try press w the console says
The animation state M9IdleAnimation(My Walking Animation) could not be played because it could not be found. ):
My idle animation is called IdleM9 just to be clear about that.
It is extremely annoying because I cannot get 1 stupid animation to play.
PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
didn't work Neutral
i created a new java script and pasted the one u posted and nothing changed
What do i do ?

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
DARTHVADEREX wrote:
didn't work Neutral
i created a new java script and pasted the one u posted and nothing changed
What do i do ?

Put the script into the object

Last edited by developer23 on Tue Jul 22, 2014 11:20 am; edited 1 time in total

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
DARTHVADEREX wrote:
didn't work Neutral
i created a new java script and pasted the one u posted and nothing changed
What do i do ?

And try this script

Code:

var AnimationClip : AnimationClip ;
function Update() {

if (Input.GetKeyDown (KeyCode.W))
{
    animation.Play();
 
}

}

descriptionWalking Animation Script(Help) EmptyRe: Walking Animation Script(Help)

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply