Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jun 01, 2016 at 08:53 PM by Dominik523 for the following reason:

The question is answered, right answer was accepted (found it myself)

avatar image
0
Question by Dominik523 · Jun 01, 2016 at 02:43 PM · unity 5scripting problemraycasttransform

Learn: Survival Shooter aim offset from mouse position

Hi everyone! So I've noticed that in Survival Shooter learn series from Unity when you shoot, line renderer and ray are bit off from mouse position. It looks like this: https://gfycat.com/KlutzySelfishConch I've tried to correct the shooting so the ray is crossing mouse pointer but unfortunately, I couldn't do it after trying everything I could think of. I tried to use "transform.LookAt(point where the ray is hitting the floor plane)" so that the end of the gun barrel object is always looking at the mouse pointer so I could just use "transform.position & transform.forward" when doing the ray cast. It's still off from the mouse pointer. This is the code for the shooting: http://pastebin.com/raw/QhQEjGmv Can someone please help me to fix this problem?

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 Dominik523 · Jun 01, 2016 at 07:49 PM 0
Share

I've found the problem. $$anonymous$$ain camera was rotated around X axis for 30 degrees. When I set it's rotation to 90 degrees so it's top down, I can see no offset. All good. But when I set back to any rotation rather than 90, the offset is back. I even tried to see if ray.direction is changing when switching rotations of the cameras, it's the same so I have no idea why is this happening.

1 Reply

  • Sort: 
avatar image
0

Answer by Dominik523 · Jun 02, 2016 at 06:15 AM

Okay, I've found the problem. Camera has been rotated around X axis fir 30 degrees. I tried to turn it to 90 degrees so it's top down only and the offset is gone. Now I'm not sure is this just visible like that or something else because the the gun is always shooting at the same position no matter how the camera is rotated. Now comes the question how to remove the offset for any camera angle...

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

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Bullethole doesn't instantiate 1 Answer

Raycast do not detect when distance is closer or further than the max distance 1 Answer

MoveTowards issue, animating ui. 1 Answer

Push object in direction of camera 0 Answers

Syncing Position and Rotation data in ECS tests? 0 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