Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SuperHB · Nov 21, 2014 at 05:48 AM · animationcharactercontrolleranimationsanimateanimating

Help with Custom Player Controller

Okay, so I'm working on my own Custom Player Controller and I'm having a few problems with the animations. What I'm trying to do is have this if statement check if the person is pressing down W and the code in the animation will call out to this variable (public var walkAnimation : AnimationClip;) which has the animation attached to it. When I start up the game it doesn't start as the idle animation, it starts half way through the walk animation... and frozen. When I make isIdle false the walk animation starts over, when I recheck isIdle it goes back the the half way frozen walk animation. Is this the correct way to do this? I'm kinda copying the code (In a more nooby way) from the Third Person Controller into my own JS Controller.

 #pragma strict
 
 //Adds Required Component to Game Object
 @script RequireComponent(null)
 
 //Identifier
 public var idleAnimation : AnimationClip;
 public var walkAnimation : AnimationClip;
 public var runAnimation : AnimationClip;
 public var sprintAnimation : AnimationClip;
 public var jumpAnimation : AnimationClip;
 public var strafeLeftAnimation : AnimationClip;
 public var strafeRightAnimation : AnimationClip;
 public var crouchAnimation : AnimationClip;
 public var crouchWalkAnimation : AnimationClip;
 public var crouchRunAnimation : AnimationClip;
 public var crouchStrafeLeftAnimation : AnimationClip;
 public var crouchStrafeRightAnimation : AnimationClip;
 
 //Animation Updater
 public var isIdle : boolean;
 public var isWalking : boolean;
 public var isRunning : boolean;
 public var isSprinting : boolean;
 public var isJumping : boolean;
 public var isStrafeLeft : boolean;
 public var isStrafeRight : boolean;
 public var isCrouched : boolean;
 public var isCrouchWalk : boolean;
 public var isCrouchRun : boolean;
 public var isCrouchStrafeLeft : boolean;
 public var isCrouchStrafeRight : boolean;
 
 //Energy Stuff
 public var canJump : boolean;
 public var canRun : boolean;
 public var canSprint : boolean;
 
 function Start () 
 {
     isIdle = true;
     isWalking = false;
     isRunning = false;
     isSprinting = false;
     isJumping = false;
     isStrafeLeft = false;
     isStrafeRight = false;
     isCrouched = false;
     isCrouchWalk = false;
     isCrouchRun = false;
     isCrouchStrafeLeft = false;
     isCrouchStrafeRight = false;
 }
 
 function Update () 
 {
     if(isIdle == true)
     {
         animation.Play(idleAnimation);
     }
     
     if(Input.GetKey(KeyCode.W) && isWalking);
     {
         //Enables walking animation
         animation.Play(walkAnimation);
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

animating, physics, and damage points... ((animating)) 2 Answers

Animations Ignore First Frame 1 Answer

Does Anyone Know What Animation System Unity3d Technologies Uses? 1 Answer

point an animation to reach target point 0 Answers

Animation problem Can't find Animate Physics 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges