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 WinslowLeach · Oct 26, 2014 at 09:44 PM · animationtransformlerpmove

How to move object from existing position to new position and change its animation?

Hello. This is my first time asking a question. I'm still a Unity newbie but have been a developer for years. I've spent hours trying to figure out how to successfully perform what I would think would be a simple task and, no matter what I've tried, it hasn't done the trick. I would post some code but I have nothing that is working.

Here's what I would like to accomplish. I have a room with a monster object in the far corner. I have a trigger in the doorway. When the FPC walks into the trigger I want the monster object to move across the room to a point in front of the door and stop. At that point I want to change the monster's built-in animation to change from it's "run" animation to it's "attack" animation. That's it. Move from point a to point b while running. Stop at point b and switch to the attack animation.

That's it. Nothing fancy but it's driving me crazy. I've spent hours working with different lerp examples, move examples, translate etc. I can get the monster to move correctly using the animation editor, but I don't know how to switch the animation from "run" to "attack" when it reaches the destination from within the animation window.

Thank you in advance to anyone who can offer some insight and guidance. Have a great day!

Ed

Comment
Add comment · Show 6
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 AlwaysSunny · Oct 26, 2014 at 09:24 PM 0
Share

Can I ask why you're trying to animate without using $$anonymous$$ecanim? It's designed around exactly these types of tasks (animating, state machines, blending between animations)

avatar image WinslowLeach · Oct 27, 2014 at 01:19 AM 0
Share

As I mentioned, I'm very new to Unity. As a web app developer, I do what I usually do and Google my way to an answer. So I Googled to find an answer to moving objects. Almost everything pointed me towards things like lerp and the various transforms. In my way of thinking I was just going after the logical answer to how to script my object to move from A to B and, when it reached B, change the animation. I could get pieces of that working, but not all of it. I will definitely do some reading up on $$anonymous$$ecanim, though.

Is $$anonymous$$ecanim for other, less complex things? Like lets just say I have a cube that I want to transition from A to B and then transform the color. Is $$anonymous$$ecanim for this kind of thing as well?

Thanks for the help!

avatar image JSierraAKAMC · Oct 27, 2014 at 02:06 AM 0
Share

$$anonymous$$ecanim is used for rigged animations, such as characters, enemies, etc. as long as you have different parts you would like to animate. Someone correct me if I'm wrong, but I don't believe it can do things like the cube movement and color change (this is an instance where'd you use lerping), but it could easily do what you're looking for.

avatar image WinslowLeach · Oct 27, 2014 at 02:23 AM 0
Share

Yeah, I'm trying to move the character object as a whole from A to B and then switch the rigged animation once it hits point B.

avatar image AlwaysSunny · Oct 27, 2014 at 03:35 AM 0
Share

When I heard monster, attack, run, I made the assumption that your scenario did or would eventually involve animations of rigged characters, and so recommended mecanim.

It's actually a choice how heavily you want to integrate its state machine package with your AI logic, but when you start from square one using it to help drive your character, it'll make it a lot easier later if-and-when the project requires anything complex like blending between multiple animations on rigged characters.

Basically, if you ever want blended animations, or you ever want to rely on animation status to help drive logic (when attack animation is at 50%, call ApplyDamage on target, for instance) then you should probably lean on mecanim to help by learning and integrating it early.

Otherwise any method of translating an object from A to B and triggering animations will suffice, and mecanim might be overkill.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by apollo25 · Oct 27, 2014 at 05:14 PM

Use mecanim animation system.You can learn here - http://unity3d.com/unity/animation you can keep a transition from idle to running at pt A. Then you can trasform.translate to pt.B. keep another trigger enter at B. Here again you can create a transition using trigger enter to change the float. hope the guidelines help.I am a newbieas well. you will be able to use mecanim after u see the 50min tut by unity....if u have any probs with triggers ortransform.translate u can refer youtube vids or API.

Comment
Add comment · Show 1 · 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 WinslowLeach · Oct 27, 2014 at 06:11 PM 0
Share

Thank you all for your guidance. I'll check things out and see if I can achieve the desired effect.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

code using lerp with input 2 Answers

Learning to move 1 Answer

Move an object down a little, then up to a position 1 Answer

move a gameobject to left/right while going up 1 Answer

Is it possible to continue a method after Input? 2 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