• 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
Question by Michael 16 · Feb 12, 2011 at 08:08 AM · animationcharacterchange

animation problem (transform.position)

I have a third person witch can boxing and throw fire balls. Every time he do hes animation it returns to the pisition where I created the animations. How can I do the animations without the character will change hes position?

here is a part of the scrip of my character:

function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

     var forward = transform.TransformDirection(Vector3.forward);
     var curSpeed = speed * Input.GetAxis ("Vertical");

     controller.SimpleMove(forward * curSpeed);

     //Shooting!
     if(Input.GetButtonDown("Jump"))
     {
          animation.Play("BodyThrow");
          var bullit = Instantiate(bullitPrefab, transform.Find("SpawnPointB1").transform.position, Quaternion.identity);
          bullit.tag = "bobProjectile";
          bullit.rigidbody.AddForce(transform.forward * 5000);
     }

     if(Input.GetKeyDown("v"))
     {
          animation.Play("BobBoxing");
     }
  }

Comment
Uriel_96

People who like this

1 Show 1
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 Michael 16 · Feb 12, 2011 at 08:15 AM 0
Share

And i need little help to delay the bullet, that he wait a second after the animation is starts, shoot, and wiat a few seconds again.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Uriel_96 · Feb 12, 2011 at 06:44 PM

to do what you want I recommend you to do your animation without moving the position of the object and then change the position of the object by code with translate and then for the delay there is something called yield WaitForSeconds that waits for the seconds you put in the parenthesis.

OK, for the yield WaitForSeconds make sure you dont put it in the Update, what I actually do sometimes to get it work is something like this:

function Update(){
DoSomething();
}
function DoSomething(){
yield WaitForSeconds(2);
//Do something
}
Comment

People who like this

0 Show 6 · 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 Michael 16 · Feb 13, 2011 at 01:06 PM 0
Share

Its still doesn't work... The animation and the delay...

avatar image Uriel_96 · Feb 13, 2011 at 03:28 PM 0
Share

for delay it may work, maybe you put it in the wrong place and for the other, you may need to see more about animation and like that get your problem because it depends on many things, like if is default or pingpong, or cross-fade so I recommend you to see more abot animation: http://unity3d.com/support/documentation/Manual/Animation.html, http://unity3d.com/support/documentation/Manual/Animation%20Scripting.html

avatar image Michael 16 · Feb 13, 2011 at 07:43 PM 0
Share

I tried everything! I just want it to do the animation only ones if I click on key and that all, it do it only ones,everything good but it return to the start point! I didn't write it on the code and you can see it not there!

About the delay, i put that code in my script but I get this error: "Script error: Update() can not be a coroutine.". What it meen?

avatar image Uriel_96 · Feb 13, 2011 at 10:08 PM 0
Share

for the animation I don't got it, some day I had that problem to, but I don't remember how I solve it, and for the delay, I forgot to say you that you can't use it in Update function, what I usually do is something that Im going to modify in the answer.

avatar image Michael 16 · Feb 14, 2011 at 06:10 PM 0
Share

Ty for Tring to help anyway. I sucsseed to add the delay finely but not the animation

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Simple character 2D-animation! (iOS) 1 Answer

Can you add animations from one rigged character to another using Mecanim? 2 Answers

Clothing Mesh not moving correctly with Character Rig, how do I fix this? 0 Answers

Mecanim issue: Twitching when blending into blendtrees 1 Answer

How to update 3D character 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