Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 kevinseligmann · Oct 08, 2011 at 08:26 AM · animationfpscharactercapsule

FPSInputController and Character Animation

Hi people, I have a doubt about the FPSInputController script. If you make a capsule, to be able to move, and rotate around, how do you manage your character's animation?.

After I make the capsule, add everything the FPSInputController controller tells you to do, I add my character and make it child of the capsule. Now, the capsule responds to WASD, mouse look and jump. So.. how can I make now so when I press W, the capsule moves AND the character walk animations plays just like it's supposed to?

I tried with:


 function LateUpdate () {
     if (Input.GetKey ("w")){
         animation.Play("WalkINPLACE");
     }
 }


Now, you can see that my animation's name is WalkInPlace, because if the capsule is moving forward... then the animation has to occur on the same place right?

I just don't thing this is the way it's supposed to make this work.

Am I missing an important part here? Do I actually have to script every key, assing them to an animation and time the capsule movement with the animation or is there an easier way?

Thanks very much!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by roamcel · Oct 08, 2011 at 04:48 PM

If you use that code in a script that you add to the actual model in your game object, then it'll work, since it'll automatically defer the 'animation' component of the model.

The possibly best way to do that is however slightly different:

declare a public variable

public Transform mymodel;

in your fpsinputcontroller script

  • drag the model, the child of your gameobject in the scene, into the 'mymodel' slot you just added

  • insert that code you have in your input controller, with a slight change: instead of your animation... line, type

    mymodel.animation.Play("WalkINPLACE");

    Additionally, you most certainly will have to set a wrapmode for the animations, in the Start function. Specifically,

    mymode.animation["WalkINPLACE"] = WrapMode.Loop;
    

    And don't forget to create a new prefab out of the new game object in the scene.

    Comment
    Add comment · Show 2 · Share
    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
    avatar image kevinseligmann · Oct 08, 2011 at 05:10 PM 0
    Share

    $$anonymous$$mmmm I will test it right away. I'll let you know, thanks!

    avatar image kevinseligmann · Oct 08, 2011 at 05:33 PM 0
    Share

    Whenever I add the line -> public Transform mymodel; -> I get this error "Unexpected token: Transform."

    And when I add -> mymodel.animation["WalkINPLACE"] = Wrap$$anonymous$$ode.Loop; -> It gives me this error "Property 'UnityEngine.Animation.Item' is read only."

    What's wrong here? (I'm working with Javascript if it's any help)

    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

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Multiplayer FPS movement and animations character 1 Answer

    Replace scriptable objects for multiple models? 0 Answers

    How to make FPS player camera see only arms and not anything else? 1 Answer

    aiming with animation 1 Answer

    How to handle multiple animation variants 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