Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 iantlloyd · May 25, 2011 at 04:44 AM · animationvelocitymouse aimfixed cameradirectional animating

Fixed Camera, Mouse aimer, How do I animate this?

Okay here's the deal, I've been going without sleep trying to work this out. Ive been using java script, but I will start using c# if that is what is needed.

I have a basic movement script on my Parent, to move on world axis. I have a child under that which my character model is on, which aims towards the mouse.

My problem is working out how to animate this player model based on the direction its facing, but also the movement the parent is doing.

Ive tried an animation script trying to use velocities, but my current hierarchy doesn't allow me to do this so easily. I think I have to start thinking of how to do this from a fresh start.

If anyone could point me in the right direction I'd be most grateful.

Comment
Add comment · Show 5
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 hellcats · May 25, 2011 at 04:54 AM 0
Share

Is your child successfully ai$$anonymous$$g towards the mouse now? What problem are you seeing? I don't understand what you mean by "animate this player model based on the direction its facing, but also the movement the parent is doing".

avatar image iantlloyd · May 25, 2011 at 04:58 AM 0
Share

Sorry I wasn't sure how to phrase this. $$anonymous$$y $$anonymous$$ouse aim is working fine, character faces towards the mouse, but my parent is moving in its own directions, I need to animate the based on how the parent is moving, but also which direction the character is pointing.

avatar image hellcats · May 25, 2011 at 05:03 AM 0
Share

So you want the parent movement to be affected by the direction that the child character model is pointing? Is the problem that when you change the parent that it also affects the child making him have to turn towards the mouse again?

avatar image iantlloyd · May 25, 2011 at 05:11 AM 0
Share

The movement is fine, character always stays aimed at mouse.

Is there a way I can read the world velocity of the parent and relay it back to the character model, but also tell which direction the character is facing and play animation based on that.

avatar image hellcats · May 25, 2011 at 05:17 AM 0
Share

If your parent has a rigidbody, then just use rigidbody.velocity. If not, then you'll have to subtract two positions on separate frames and divide by Time.deltaTime. Once you have this velocity in global coords, you can convert it to local coords of your child by using:

localVelocity = child.transform.InverseTransformDirection(velocity)

This will be the velocity of the parent, but in the child's coordinate system (which takes into account the direction the child is facing). You can use this to decide which child animation to do.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by iantlloyd · May 26, 2011 at 06:33 AM

I ended up setting up some triggers, and whatever trigger the character was pointing at it would swap the keys for the animation cycles. I don't think its very efficient, but it works for now.

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

1 Person is following this question.

avatar image

Related Questions

How do I access the "Average Velocity" of a run animation? 1 Answer

Check if FPS Character Controller Is Moving Then Switch Animations 2 Answers

2D platformer composite collider animation bug 2 Answers

Velocity and Animator change while game is Paused 1 Answer

Velocity powered rigidbody on a moving platform without parenting. 3 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