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

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Walking Animation Script(Help)

Walking Animation Script(Help)

Go to page : 1, 2  Next

View previous topic View next topic Go down  Message [Page 1 of 2]

1 Walking Animation Script(Help) on Tue Jun 03, 2014 2:01 am

Espon17


Member [Lv. 0]
Member [Lv. 0]
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.

View user profile

2 Re: Walking Animation Script(Help) on Tue Jun 03, 2014 5:18 pm

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");
 }
}

View user profile http://www.youtube.com/user/misterninjaboy

3 Re: Walking Animation Script(Help) on Wed Jun 04, 2014 10:29 am

developer23


Moderator
Moderator
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

View user profile http://masterdevelopers.altervista.org/

4 Re: Walking Animation Script(Help) on Wed Jun 04, 2014 11:59 pm

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

View user profile http://www.youtube.com/user/misterninjaboy

5 Re: Walking Animation Script(Help) on Thu Jun 05, 2014 6:49 am

developer23


Moderator
Moderator
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

View user profile http://masterdevelopers.altervista.org/

6 Re: Walking Animation Script(Help) on Thu Jun 05, 2014 8:11 am

yashtewarisaab


Member [Lv. 0]
Member [Lv. 0]
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

View user profile

7 D: on Sat Jun 28, 2014 12:30 am

daniel202gaming


Member [Lv. 0]
Member [Lv. 0]
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

View user profile

8 Re: Walking Animation Script(Help) on Tue Jul 22, 2014 9:08 am

DARTHVADEREX


Member [Lv. 2]
Member [Lv. 2]
didn't work Neutral
i created a new java script and pasted the one u posted and nothing changed
What do i do ?

View user profile

9 Re: Walking Animation Script(Help) on Tue Jul 22, 2014 11:15 am

developer23


Moderator
Moderator
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

View user profile http://masterdevelopers.altervista.org/

10 Re: Walking Animation Script(Help) on Tue Jul 22, 2014 11:18 am

developer23


Moderator
Moderator
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();
 
}

}

View user profile http://masterdevelopers.altervista.org/

11 Re: Walking Animation Script(Help) on Tue Jul 22, 2014 11:19 am

developer23


Moderator
Moderator
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();
 
}

}

View user profile http://masterdevelopers.altervista.org/

12 Re: Walking Animation Script(Help) on Wed Jul 23, 2014 2:53 am

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
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?

View user profile

13 Re: Walking Animation Script(Help) on Wed Jul 23, 2014 3:28 am

developer23


Moderator
Moderator
Sorry but works for me, i haven't idea because doesn't works for you

View user profile http://masterdevelopers.altervista.org/

14 Re: Walking Animation Script(Help) on Wed Jul 23, 2014 1:26 pm

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
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

View user profile

15 Re: Walking Animation Script(Help) on Wed Jul 23, 2014 1:55 pm

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
Here is the video to my problem:
https://www.youtube.com/watch?v=HaGxoRZi8E4&list=UU03K626PqGtDR9ucffWfpLA

View user profile

16 Re: Walking Animation Script(Help) on Wed Jul 23, 2014 3:59 pm

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
Well, now I took the scripts out, then I put it back in, and now it wont work at all.

View user profile

17 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 2:34 am

developer23


Moderator
Moderator
What version of Unity is it?

View user profile http://masterdevelopers.altervista.org/

18 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 9:54 am

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
Unity 4: version 4.5.1f3. Is that the same version you use?

View user profile

19 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 11:04 am

developer23


Moderator
Moderator
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)

View user profile http://masterdevelopers.altervista.org/

20 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 11:16 am

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
I have the animation set to it, and now it only does it once, if I dont push w or if I do.

View user profile

21 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 11:30 am

developer23


Moderator
Moderator
Try to remove play automatically in Animation component

View user profile http://masterdevelopers.altervista.org/

22 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 11:46 am

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
Um, where is that?

View user profile

23 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 8:37 pm

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
Now I have a new problem. It needs to be marked as "legacy." I have no idea what that means.

View user profile

24 Re: Walking Animation Script(Help) on Thu Jul 24, 2014 9:50 pm

FainterStreaker


Member [Lv. 3]
Member [Lv. 3]
After two countless, nonstopping days of trying to figure it out, I finally figured it out. Im going to bed.

View user profile

25 Re: Walking Animation Script(Help) on Fri Jul 25, 2014 2:51 am

developer23


Moderator
Moderator
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

View user profile http://masterdevelopers.altervista.org/

View previous topic View next topic Back to top  Message [Page 1 of 2]

Go to page : 1, 2  Next

Permissions in this forum:
You cannot reply to topics in this forum