Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Share
Go down
Member [Lv. 0]
Member [Lv. 0]
Posts : 1
Points : 1511
Rep : 0
Join date : 2014-06-02
View user profile

Walking Animation Script(Help)

on Tue Jun 03, 2014 2:01 am
Message reputation : 50% (4 votes)
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.
avatar
Admin
Admin
Posts : 608
Points : 3167
Rep : 406
Join date : 2013-12-11
Age : 21
View user profilehttps://www.youtube.com/user/misterninjaboy

Re: Walking Animation Script(Help)

on Tue Jun 03, 2014 5:18 pm
Message reputation : 57% (7 votes)
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");
 }
}
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Wed Jun 04, 2014 10:29 am
Message reputation : 100% (1 vote)
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
avatar
Admin
Admin
Posts : 608
Points : 3167
Rep : 406
Join date : 2013-12-11
Age : 21
View user profilehttps://www.youtube.com/user/misterninjaboy

Re: Walking Animation Script(Help)

on Wed Jun 04, 2014 11:59 pm
Message reputation : 100% (2 votes)
It essentially does the same thing. Also developer 23, I reccomend you use animation.crossfade insdead of animation.play.
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Thu Jun 05, 2014 6:49 am
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
Member [Lv. 0]
Member [Lv. 0]
Posts : 1
Points : 1506
Rep : 0
Join date : 2014-06-05
View user profile

Re: Walking Animation Script(Help)

on Thu Jun 05, 2014 8:11 am
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
Member [Lv. 0]
Member [Lv. 0]
Posts : 1
Points : 1485
Rep : 1
Join date : 2014-06-27
View user profile

D:

on Sat Jun 28, 2014 12:30 am
Message reputation : 100% (1 vote)
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
Member [Lv. 2]
Member [Lv. 2]
Posts : 6
Points : 1470
Rep : 0
Join date : 2014-07-18
View user profile

Re: Walking Animation Script(Help)

on Tue Jul 22, 2014 9:08 am
didn't work Neutral
i created a new java script and pasted the one u posted and nothing changed
What do i do ?
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Tue Jul 22, 2014 11:15 am
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
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Tue Jul 22, 2014 11:18 am
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();
 
}

}
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Tue Jul 22, 2014 11:19 am
daniel202gaming wrote:
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
Try this:
Code:
var AnimationClip : AnimationClip ;
function Update() {

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

}
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Wed Jul 23, 2014 2:53 am
Hmmm... I try to put the script in the gun, (the walking and the stop animation, and I get this:

Code:
The AnimationClip 'walking' used by the Animation component 'CSS Arms FBX' must be marked as Legacy.

Not sure what "Legacy" means...

Here is my scripts for both of the things:

Walking:
Code:
  function Update()
{
 if(Input.GetKeyDown("w"))
 {
  // Plays the walking animation - stops all other animations
  animation.Play("walking", PlayMode.StopAll);
 }
}

WalkingStop:

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

Obviously, I have no idea what any of that means. Can you help me please?
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Wed Jul 23, 2014 3:28 am
Sorry but works for me, i haven't idea because doesn't works for you
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Wed Jul 23, 2014 1:26 pm
I dont know why its not working for me either... I have the code and everything. Im wondering if the animation setup came with a plugin that was needed to make it work? If thats so, I need the download url please
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Wed Jul 23, 2014 1:55 pm
Here is the video to my problem:
https://www.youtube.com/watch?v=HaGxoRZi8E4&list=UU03K626PqGtDR9ucffWfpLA
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Wed Jul 23, 2014 3:59 pm
Well, now I took the scripts out, then I put it back in, and now it wont work at all.
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 2:34 am
What version of Unity is it?
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 9:54 am
Unity 4: version 4.5.1f3. Is that the same version you use?
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 11:04 am
FainterStreaker wrote:Unity 4: version 4.5.1f3. Is that the same version you use?
Yes,you just go on window,animator,and under the text Any State add you animation (drag the animation in the Animator)
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 11:16 am
I have the animation set to it, and now it only does it once, if I dont push w or if I do.
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 11:30 am
Try to remove play automatically in Animation component
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 11:46 am
Um, where is that?
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 8:37 pm
Now I have a new problem. It needs to be marked as "legacy." I have no idea what that means.
Member [Lv. 3]
Member [Lv. 3]
Posts : 17
Points : 1509
Rep : -1
Join date : 2014-06-26
View user profile

Re: Walking Animation Script(Help)

on Thu Jul 24, 2014 9:50 pm
After two countless, nonstopping days of trying to figure it out, I finally figured it out. Im going to bed.
avatar
Moderator
Moderator
Posts : 329
Points : 2174
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: Walking Animation Script(Help)

on Fri Jul 25, 2014 2:51 am
FainterStreaker wrote:After two countless, nonstopping days of trying to figure it out, I finally figured it out. Im going to bed.
Then problem solved? Smile
Back to top
Permissions in this forum:
You cannot reply to topics in this forum