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 Aaal · Apr 22, 2013 at 03:22 PM · raycastingraycasthit

Raycasting issue for maximised screen

Hi All,

I have 2 game objects. One is a character model and the other is just an object about half the height of the character. I have game and scene views on my computer screen at the same time. When playing in such a layout, my raycasting works fine but whenever I maximise my screen, the raycasting is unable to detect the object in front of my character. Why is this so? Is there some issue with my origin parameters?

Exactly the same code I used for my testing as shown below. Theoretically-wise, what went wrong? Both have colliders and my character is able to knock against it. One weird thing I notice is when I maximise the "play" mode, the object seems to be 1/3 the height of my character instead of 1/2. Thanks.

if(Physics.Raycast(thePlayer.transform.position, thePlayer.transform.TransformDirection(Vector3.forward), out hit, 3)) Debug.Log("ok");

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ahaykal · Apr 22, 2013 at 04:01 PM

Check the z position of your character.

Try to place them far away from each other and check if the raycast is hitting.

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 Aaal · Apr 23, 2013 at 02:41 AM 0
Share

thanks ahaykal!

avatar image
0

Answer by Aaal · Apr 23, 2013 at 02:40 AM

Answering my question for the benefits of others. If using a smaller screen when in play mode works but not when it is maximised, do extend the bottom side of the collider of the object.

You may use debug.drawray or debug.drawline to check the rays. Remember to turn on your gizmos.

I have never expected when both my character and the object which start at the same Y values, when maximised, there is a slight offset on the object. It is slightly higher. Thus, the rays emaciating from the player are unable to hit on the object.

Funny issue, could be my problem, but just extending the bottom collider will simply solve it.

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.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

[help]RayCast check [SOLVED] 2 Answers

issues with raycasts 0 Answers

raycasting gun hitting random spawned enemies when shooting at one of them? 2 Answers

Multiple hit detection with Raycasting? 2 Answers

Drawing a ray as a Cylinder between two moving objects 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