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 dendens2 · Mar 10, 2013 at 03:19 AM · rotationtransformfpsgun

Rotation/position question.

So I am making a script to stick my gun to the players screen, however, for some reason there is a delay when I look around (like in battlefield 3/planetside 2). I don't want this to happen and it is causing my gun to jitter. I can't figure out what is wrong. This script runs in the gun.

     transform.position = cameraObject.transform.position;
     rotationTarget = cameraObject.transform.rotation;
     transform.rotation = rotationTarget;
Comment
Add comment · Show 2
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 hoy_smallfry · Mar 10, 2013 at 03:31 AM 1
Share

Why don't you just make the gun a child of the camera in the hierarchy?

avatar image dendens2 · Mar 10, 2013 at 06:20 AM 0
Share

Because I have code that drops it as well as some others and I don't know how I would have to rework it to make it work. Thing is that I had it work and now it's not working :\

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by nsxdavid · Mar 10, 2013 at 03:34 AM

Do either:

Make the gun a child of the camera (as suggested above)

If your movement is done in physics and/or FixedUpdate(), then gun placement should as well.

Check your script order execution. Consider gun placement in LateUpdate() instead of Update()

Comment
Add comment · Show 5 · 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 dendens2 · Mar 10, 2013 at 06:21 AM 0
Share

It's already in a LateUpdate() and look at my comment above.

avatar image Catlard · Mar 10, 2013 at 06:31 AM 0
Share

Woo! what a snarky reply to a good answer. Dendens, don't take the easy way out of coding something just because you don't know how to do it the right way. It probably sounds silly, but you're just cheating yourself. Good answer, nsxdavid.

avatar image dendens2 · Mar 10, 2013 at 07:22 AM 0
Share

It wasn't a snarky reply. All I said is that in my situation his solution would not work with my other code. Anyways I just found out that I can parent and unparent through code so I actually am going to try it. When I am done I'll message back.

avatar image Catlard · Mar 10, 2013 at 09:19 AM 0
Share

Ok, sorry then -- hard to tell people's tones. Oh, yes! Parenting and unparenting through code. Good call.

avatar image dendens2 · Mar 10, 2013 at 07:45 PM 0
Share

Ok, so parenting and unparenting through the code worked, thanks! :D

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

13 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 avatar image

Related Questions

Gun not rotating with the camera? 1 Answer

Transform rotation 2 Answers

gun rotation fps 0 Answers

Aiming down a gun 4 Answers

why wont machine gun follow first person controller 2 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