Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 question was closed Nov 12, 2016 at 04:35 AM by Sgt-Bad-Touch for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Sgt-Bad-Touch · Nov 07, 2016 at 10:47 PM · rotationraycasttransformquaternionlookat

Have An Object Rotate Around Transform A So That Transform B is Looking at Transform C (C#)

I have a player holding a rifle. In this rifle Game Object there are two transforms. Transform 'A' for the point which the butt-stock of the rifle meets the player's shoulder, and Transform 'B' which is aligned with the weapon's barrel.

Outside of the rifle Game Object there is Transform 'C', this transform is a Ray cast intersection, this represents what the player is looking at. I already have this done.

The rifle needs to rotate around Transform 'A' so that Transform 'B' is always pointing at Transform 'C'.

I had tried messing around with Quaternion Look Rotation, but got completely lost. I'm having a hard time finding a place to start.

Any help greatly appreciated (in C#), thanks.

Here are some diagrams:

alt text

alt text

rifleaim2.jpg (53.3 kB)
rifleaim.png (222.8 kB)
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 doublemax · Nov 09, 2016 at 10:05 PM 1
Share

Create a new empty game object and add the rifle to it as a child. $$anonymous$$ove the rifle so that point A is at the pivot point of the parent object. $$anonymous$$ake sure the rifle points into the direction of the Z-axis of the parent.

Then transform.LookAt( pointC.position ) should make the rifle point at the target.

avatar image Sgt-Bad-Touch doublemax · Nov 12, 2016 at 04:34 AM 1
Share

This works, man. Thanks.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Child transforms screwed up by parent's rotations 1 Answer

How to clamp the rotation of this? 0 Answers

Get slerp to work just as LookAt(,Vector3.right) does 1 Answer

Object slope rotation issue 0 Answers

Unity Rotate Raycast on Quaternion 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