• 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 agamedesigner · Aug 23, 2012 at 04:03 AM · characterproceduralaimaimingprocedural animation

Procedural character aiming

I have a character (in 3rd person) aiming down the sight of their gun. I'm shooting projectiles straight out of the end of the gun, but it doesn't match up with the crosshair.

What I'm trying to do is make it aim at the crosshair at any distance (at the $$anonymous$$t point of a raycast, or the end of the ray if not$$anonymous$$ng is $$anonymous$$t), so that whether you're aiming at somet$$anonymous$$ng near or far, the character will adjust their aim to always $$anonymous$$t the center of the crosshair.

I've tried a few different t$$anonymous$$ngs, such as having the right arm rotation (the left arm/gun/head follow t$$anonymous$$s transform's rotations) linked to an empty gameobject w$$anonymous$$ch looks at the correct point; I've also tried manually adding to the rotation through scripting but t$$anonymous$$s is a far from ideal solution as it needs to be adjusted for every individual (aiming) animation present and seems to be rather inaccurate anyway.

I was wondering if anyone had any thoughts or experience on t$$anonymous$$s. Perhaps (hopefully) I am overlooking somet$$anonymous$$ng simple that I could do to resolve t$$anonymous$$s.

Comment

People who like this

0 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 Khada · Aug 23, 2012 at 09:52 AM 1
Share

Is this am FPS? Generally they don't move the guns rotation to aim 'exactly' at where the bullet will collide with an object. Instead the gun just looks like it's aiming toward the center of the screen then you adjust the direction of the bullet based on the picking/raycasting method you mentioned.

EDIT: Stupid question, your question states that it's a 3rd person game. My mistake. Apologies.

avatar image tigerfoot · Aug 23, 2012 at 10:42 AM 0
Share

Can you post the code for the aiming you use? After looking at it we might be more helpful...

avatar image agamedesigner · Aug 31, 2012 at 07:07 PM 0
Share

Sorry for the delayed response, was out of town. The code is dogzer's (search for dogzer on the asset store and you'll find his free character with aiming scripts).

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by everygamer · Aug 23, 2012 at 12:50 PM

Sounds to me that if your in a 3rd person perspective your not looking right down the barrel of the gun..T$$anonymous$$s implies there is an angle between your line of sight and where the bullet is going..The cross hairs are likely stationary to your view and set a specific distance from your character. So mattering how far away and there relative position to you, your target would change the angle and where the cross hair would need to be placed to line up with the shot.

What t$$anonymous$$s means is you would need to constantly calculate and move your crosshairs to correct the angle.

T$$anonymous$$s is why shooters are 1st person perspective, it cuts out that angle and makes the line of sight line up with the line the bullets travel, and or at least minimizes it by keeping he angle on the y-axis and they make a sliht adjustment to the cross hairs position.

The other t$$anonymous$$ng you could look at doing is pick a point in space where the crosshair/bullets will intersect. T$$anonymous$$s would keep the cross hair fixed, and different guns could have different effective ranges. It would make it most accurate in specific situations and less in others.

Comment

People who like this

0 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 agamedesigner · Aug 31, 2012 at 07:12 PM 0
Share

Sorry for the delayed response, I was out of town. But yeah, doing it with the scripts I was using (modified version of dogzer's soldier aim script) has produced pretty undesirable results. The character does aim at the crosshair properly at any distance, however there are a few other issues that arise, and I know that fixing them is going to take longer than this kind of setup is even worth. So I think what I'm going to do is just use pre-animated aim poses and blend between them. It will be a lot faster to set up and much more smooth looking. As far as the IK, I don't even need an IK in Unity anyway, I can just have one in Maya and then bake the animation and of course the IK's influence on the animation comes through.

avatar image

Answer by create3dgames · Aug 31, 2012 at 07:27 PM

Check out Unity's 3rd person shooter example or the Bootcamp demo.

Comment

People who like this

0 Show 0 · 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.

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

11 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

Related Questions

how to make a character lean over or back when looking up or down 2 Answers

Third person controller aiming 1 Answer

How would I rotate an object based on four Vector3 Points 0 Answers

I need help on how to make a Aim Assist aka Auto AIm 3 Answers

How to make character arms/head aim up/down following crosshair? 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