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 /
This question was closed Jul 02, 2014 at 01:35 PM by meat5000 for the following reason:

Google is your friend

avatar image
-1
Question by seb-lopez · May 31, 2014 at 10:15 PM · camerafollowcrosshairtps

third person shooter player follow the crosshair

hi , im having a hard time finding a correct way to make the hero looking straight to the cross hair when pressing the mouse button (like in dead space or gta ) i thought using a look at script type but haven't succeed. i was hoping that someone could show me how to make it happened or just point me to a tutorial on it.

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 Hadid · Mar 17, 2016 at 06:02 AM 0
Share

i have understanded your problem statement what you want is

Cam = GameObject.FindGameObjectWithTag("$$anonymous$$ainCamera");

Player.transoform .rotation = Quaternion.Slerp(Player.transform.rotation,Quaternion.Euler(new Vector3(Player.transform.rotation.x,Camera.rotation.eulerAngles.y,Player.transform.rotation.x));

this line of code will make your player rotation linear with camera

1 Reply

  • Sort: 
avatar image
1

Answer by Firedan1176 · May 31, 2014 at 10:34 PM

If you use LookAt, you'd have to make sure the crosshair is touching the object he's aiming at. I would say the best way to go about doing this is to use Raycast (Look up physics.RaycastAll). If you shoot a raycast when the user clicks, you can use RaycastAll to get the hit point (where the raycast hits an object) and have the gun use Look At to look at the hit point.

(I went through a little time to draw you an example below)

http://i59.tinypic.com/2ho92io.png

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 seb-lopez · Jun 01, 2014 at 12:30 AM 0
Share

hmmm(i might bad explained ) sorry but its not what i wanted But it is a neet example to use later on my project . but what i really wanted is to rotate the player in the direction of the camera . ( each time you turn the camera the player follows the camera axis.

tell me if its still bad explain ( im really bad in explanation's in English)

same as always tutorial link will also help me ( and direct script example also).

Follow this Question

Answers Answers and Comments

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

Related Questions

rotate camera on mouse reaching edges 1 Answer

camera follow problem-unity 4.3 2d 1 Answer

2D Camera Smooth follow, FixedUpdate and LateUpdate odd difference, help needed. 1 Answer

Crosshair Not Parallel To camera 1 Answer

Raycast based on crosshair on screen 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