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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by PabloArty · Mar 18, 2013 at 06:04 PM · 2daimingarm

Arm aiming in 2D. Please Help.

Morning!

I'm creating a game in 3D/2D I mean somthing like Smash Bros, Kirby64 and that kind.

Well, I have a few weeks, so I can not model and animate a character and I'm using the third person prototype from Unity but changing textures and adding armor on him.

My problem is when I try to make his arm follow the mouse because it is preanimated and the interaction cross with the animation, so I want to ask you people if there is some way to take off the arm from the animation or something that let me guide the arm with the mouse.

I'm using this code.

 #pragma strict
 
 var mouse_pos : Vector3;
 var target : Transform; //Assign to the object you want to rotate
 var object_pos : Vector3;
 var angle : float;
  
 function Update ()
 {
     mouse_pos = Input.mousePosition;
     mouse_pos.z = 15; //The distance between the camera and object
     object_pos = Camera.main.WorldToScreenPoint(target.position);
     mouse_pos.x = mouse_pos.x - object_pos.x;
     mouse_pos.y = mouse_pos.y - object_pos.y;
     angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
     transform.rotation = Quaternion.Euler(Vector3(0, 0, angle));
 }

And i know that works cuz all the character rolls in a crazy weird dancing and its cuz the interaction cross with the animation. Well I think thats the reason.

Thnx! I hope you can help me, have a nice day (:

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
2

Answer by Loius · Mar 18, 2013 at 06:07 PM

Rotate the arm in LateUpdate instead of Update (animation happens between Update and LateUpdate). You could also just not animate the arm in your animation, though I know for sure that Blender's default FBX exporter always exports animation for every bone, so unless you can get at its exporter you'll need to use LateUpdate.

Note that you have to be careful when creating your bones, or your arm's initial rotation may be such that it's difficult to rotate without extra work. The bone's length is one axis; try to get the other axes to point straight up/left for best results.

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 PabloArty · Mar 18, 2013 at 06:23 PM 0
Share

then I should change to function LateUpdate?

the problem with the animation is that im using the third person prototype from Unity Assets, I dunno if I can change the animation of it in Cinema 4D or something.

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

12 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

Related Questions

Flipping shot point 2d shooter 1 Answer

Looking and firing towards mouse position, 2d game. 3 Answers

How to aim gun using 2D IK with a fixed elbow rotation? 0 Answers

2D Animation does not start 1 Answer

I'm trying to make it so when I left click, my character's sword slash sprite appears towards the direction of the mouse 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