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 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 hit point of a raycast, or the end of the ray if nothing is hit), so that whether you're aiming at something near or far, the character will adjust their aim to always hit the center of the crosshair.

I've tried a few different things, such as having the right arm rotation (the left arm/gun/head follow this transform's rotations) linked to an empty gameobject which looks at the correct point; I've also tried manually adding to the rotation through scripting but this 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 this. Perhaps (hopefully) I am overlooking something simple that I could do to resolve this.

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 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. Ins$$anonymous$$d the gun just looks like it's ai$$anonymous$$g 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. $$anonymous$$y mistake. Apologies.

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

Can you post the code for the ai$$anonymous$$g 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 ai$$anonymous$$g scripts).

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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..This 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 this means is you would need to constantly calculate and move your crosshairs to correct the angle.

This 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 thing you could look at doing is pick a point in space where the crosshair/bullets will intersect. This 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
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 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 I$$anonymous$$, I don't even need an I$$anonymous$$ in Unity anyway, I can just have one in $$anonymous$$aya and then bake the animation and of course the I$$anonymous$$'s influence on the animation comes through.

avatar image
0

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

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

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

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

Aiming Gun at Cursor 2 Answers

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

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

How to make character arms/head aim up/down following crosshair? 1 Answer

Third person controller aiming 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