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 netspider86 · Nov 08, 2011 at 04:12 PM · animationrotationarmature

Animating (simple rotation) armature by script

I tried to look around a bit, but I didn't find exactly what I was looking for... I'm new to Unity, so I'm basically just playing around with stuff, trying to understand how things work. I got a bit stuck on animating parts of a character by using the code.

1) how should I access various bones from the script? I attached my script to the player object, and I think the right hierarchy to access the neck transform should be Armature.upper_spine.neck.transform, by how my gameobject looks like, but it's not working at all. Instead it works [sort of] fine with GameObject.Find("neck") or by creating a script explicitly for the neck and attaching it to the "neck" object. Is there a more correct way to access various bones in the hierarchy?

2) in both the ways described above, I tried to reproduce what I already did with the whole mesh, that is rotating while a key is pressed (w\ the Q and E keys). If I do that directly on the gameObject (transform.Rotate), the whole character keeps rotating while the key is pressed, but on the neck it just rotates by the angle I specify as a parameter and stops there. This happens with both methods described in point 1) to access a bone (neck).

In addition to this, the neck seems to work only if I call the methods from LateUpdate, while the entire character works in the Update, too. (I know I should use coroutines, still working on that).

Why is this happening? Do objects and bones simply work differently? I found a good piece of code online that helped me a bit (saving the rotation in a variable, then looping the new rotation value in a coroutine), but I still don't understand the reason for this difference.

Thanks in advance!

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

Answer by softrare · Nov 09, 2011 at 07:51 AM

I don't know if that is what you are looking for but by animation by script I understand something like the following code. It is code I use for a demo for our asset store package of which there is a demo here. The script rotates the helix from a chopper.

public Transform topHelix; public float speed;

void FixedUpdate () {

 float helixSpeed = 200f * speed;
 topHelix.localEulerAngles= new Vector3(topHelix.localEulerAngles.x,topHelix.localEulerAngles.y,topHelix.localEulerAngles.z+helixSpeed);     

}

Comment
Add comment · 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

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

Armature stuck on a single side after an animation 0 Answers

Problem with animation: they always start at the same rotation!! 1 Answer

Animate a cube rotation with script only 3 Answers

Rolling cubes one space and one rotation at a time, with a delay 2 Answers

Reseting armature's rotation in Unity 0 Answers


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