Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
Blockfighter298

Character Animations [NEED HELP!]

Question

Hello,
I know this is maybe a stupid question, but i can't just figure it out.
I thought it was something simple to do but its not working fine :(
 
I want to know how to get the Crossfade work for animations.
 
My script im using:
Please login or register to see this code.
 
My setup im using (Just the standard FPS Controller) :
XldNcd5.png
 
The problem:
First you need to know that i have attached the standard mouselook script on the Main Camera.
I have attached this script to the Main Camera, but when i play the walk animation when playing the game. 
(I mean when i just walk with the fps controller)
 
Then the mouselook resets himself when any of the controls (WASD) are pressed down.
 
 
________________________________________________________________
Yes i know, i have checked already all over the scripting reference from Unity to.
 
I really need a script which works clean with the following animations that can blend/crossfade together:
-Run
-Walk
-Jump
*additionals*:
-Lean Right while walking

-Lean Left while walking

 

Please i need help from the pro scripters ^_^

 

 

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

1 thing is at the top of your script you state it was written by you but it is found here: Please login or register to see this link. But as for the problem, you say it resets itself when the vertical inputs are pressed? Sounds like there is some other script that is accessing or controlling the animated objects position/rotation or the animation itself is messed up. With such little bit of code, it shouldn't mess up for any other reason unless this script is not attached to the object that has the animations attached

Share this post


Link to post
Share on other sites

  • 0

Ok, look im just using the default package from Unity their Character Controller. And ive only added this script and nothing else. But how to fix? :(

Share this post


Link to post
Share on other sites
  • 0

Is the walk and idle animations attached to the object that the script is attached to and is the animations playing as it should in the animation panel?

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Ok, the Main Camera includes:

-The script you've seen above

- 1 main animation (Idle)

- 2 attached animations (Idle and Walk)

 

With "main animation" i mean the space where you can fill in the default animationclip onto the gameobject (Main Camera)

 

Just look at the image. I know my english isn't so good. :/

VLeoCmv.png

 

I have also tryed with setting the "Play Automatically" off, but doesn't make a difference.

Culling type not either. How can i ever attach animations (walk animations) to the main camera then?

I need help!

Edited by Blockfighter298

Share this post


Link to post
Share on other sites
  • 0
if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0)
animation.CrossFade("Walk");
else
animation.CrossFade("Idle");

 

or

 

if (Input.GetButtonDown(W))
animation.CrossFade("Walk");
else
animation.CrossFade("Idle");

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Ok, i'll try it later.

Im now also working on my next project wich is based on the "Source Engine". Used by games like Half-Life 2 and Counter Strike : Source

Im taking gamedevelopment to a higher level :d

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...