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 DocMcShot · Oct 17, 2014 at 06:30 PM · animationpositionmecanim

Is it possible to use a random spawn position as a keyframe in an animation?

I'm working on a 2d game and here's what I've got. I'm spawning some prefabs right outside of the camera view. What I would like to do is to be able to use that spawn position, as a position keyframe in an animation. This way I can move the animation to the location on the screen that I want.

The way I have things setup now, my objects spawn location depends on the size of the device's screen. I get the world point by using ViewportToWorldPoint and then subtract the sprite extents so the object spawn immediately off the screen. I have also defined dynamic screen locations (depending on device screen size), that I would like to move my the gameObject to.

Ideally I would like to be able to use Mecanim to interpolate from my spawn point to the end point.

Is this even possible with Mecanim? If so, can you point me in the right direction? Thanks!

Comment
Add comment · Show 3
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 DocMcShot · Oct 18, 2014 at 04:32 PM 0
Share

Anyone... Please :)

avatar image b1gry4n · Oct 18, 2014 at 04:38 PM 0
Share

Have you tried using the event system? Both mecanim animations and the unity Animation window allow you to specify a specific key frame to handle an event. From that event you can do anything you want in code

Since you dont know the spawn position, on a specific key frame you would trigger an event that would look for the position and update whatever you need to update

I am not sure what exactly you are animating but it sounds like you want to position an object where youve spawned an enemy and play an existing animation? If that is the case you could simply make your object a child of an empty game object. $$anonymous$$ove that empty game object to the spawn location and your animation will be playing in "local" space

Unless what you are asking is if you can update an animations data at runtime. I dont know about that

avatar image DocMcShot · Oct 18, 2014 at 04:59 PM 0
Share

What I'm trying to do is spawn an object off of the screen and have it slide on to the screen to a specific point. I have calculated the specific point based on the screen size. I also have calculated the final resting point of the sprite based on the screen size.

I think I can make it work through the event system. I was just wondering if there was a way to override the transform of the Animation window so that I can control moving the position of the gameObject through mecanim.

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

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I make mecanim animations respect bone location/position keyframes? 0 Answers

Keep position/transform of object after animation 0 Answers

Misplaced Character with Mecanim 1 Answer

position change due to animation 1 Answer

Mecanim animation make the model slide slowly! 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