• 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 fpsteele · Sep 21, 2011 at 07:08 PM · fpsaiming

Fps Aiming Script help

can someone help me, either by showing me, or by a link how to get my pistol to aim down sights, i have seen many different one's and none work for me, i have my glock under the glock folder under my first person player thanks

Comment
Add comment · Show 1
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 syclamoth · Sep 22, 2011 at 01:39 AM 0
Share

Could you post a specific problem here? We can't really help you unless we know exactly what you want to do, and why other solutions aren't working for you.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AlanChatham · Sep 22, 2011 at 07:11 AM

Are you trying to get your weapon to fire to the center of the player's camera (i.e. where you would draw the reticle)? This snippet fires a ray from the player's camera straight forward, so it's not actually the weapon firing in that direction, the fire comes straight from the camera.

 function Fire(){
     var playerCamera = Camera.main;
     var hit : RaycastHit;

     // Do a raycast forward from the camera to see if we hit a solid object
     if (Physics.Raycast (playerCamera.transform.position, direction, hit, range)) {
             // Apply a force to any rigidbody we hit
         if (hit.rigidbody)
             hit.rigidbody.AddForceAtPosition(force * direction, hit.point);

         // Send a damage message to the hit object            
         hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
     }
 }

Of course, you're probably best off working through that tutorial and seeing everything there yourself - http://unity3d.com/support/resources/tutorials/fpstutorial.html

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 CHPedersen · Sep 22, 2011 at 07:18 AM 0
Share

Good effort, but I think he's trying to create an animation so that the pistol gets raised from a relaxed position (eg while running) to an ai$$anonymous$$g position (where the top of the pistols sort of aligns with the camera, so you get the feeling you're looking down the sights).

That particular effect is probably most easily accomplished by creating it as an animation in whatever modeling application the player character came from, and then playing that animation at the push of a button in Unity.

avatar image
0

Answer by fpsteele · Sep 23, 2011 at 11:57 PM

thanks chris, im using blender, but can the animation transfer to unity also? ill try i guess

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.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

my character damage script wont work 1 Answer

Aiming down a gun 1 Answer

How To Add A FX When I Teleport. 0 Answers

A node in a childnode? 1 Answer

Unity,How to make training Target Enemy 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