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 Drmrsrteachersr · Aug 20, 2013 at 07:33 PM · errorpositionraycastingtransform.positiondebug

Raycast from the wrong position.

alt text

This Ray should be casting from the position of this player so I cant figure out why this keeps happening. The picture isn't the worst I've seen either. Any reason why the ray is not starting from the players position.

 var ray = Ray(transform.position,-gravityVector*30);
 found = Physics.Raycast(ray,hit,30);
 Debug.DrawRay(transform.position,-gravityVector*30);

untitled.png (38.4 kB)
Comment
Add comment · Show 3
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 Joyrider · Aug 20, 2013 at 07:36 PM 0
Share

I am just asking to make sure... the script is on the selected capsule from the picture?

avatar image Drmrsrteachersr · Aug 20, 2013 at 09:36 PM 0
Share

yes its on the capsule you see there

avatar image Xtro · Aug 21, 2013 at 12:09 AM 0
Share

I tested your code on the capsule and it works perfect. can you put a screenshot of the incpector window? displaying the capsule object and scrict component???

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by moghes · Aug 20, 2013 at 09:32 PM

to which object you have attached your script?

what is transform.position

Do a debug for transform.position, pause the game and check if your player's position is the same as you read in the console.

You can have a small sphere as a child to your player, remove the renderer component, and name your sphere "ray origin" or something (this is optional). Then attach your script to this sphere, and check if the ray comes out from it.

Comment
Add comment · Show 4 · 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 Joyrider · Aug 20, 2013 at 09:34 PM 2
Share

@moghes, this should be comment, not an answer

avatar image moghes · Aug 20, 2013 at 09:49 PM 1
Share

"You can have a small sphere as a child to your player, remove the renderer component, and name your sphere "ray origin" or something (this is optional). Then attach your script to this sphere, and check if the ray comes out from it." doesn't this make sense?

avatar image Joyrider · Aug 20, 2013 at 10:04 PM 1
Share

well sounds more like a test than a solution, but whatever.

avatar image Xtro · Aug 21, 2013 at 12:03 AM 0
Share

tests are solutions sometimes. :)

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

18 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

Related Questions

C# script failing silently? 0 Answers

Texture disappears in standalone (fine in editor)? 1 Answer

GooglePlayServices & GoogleMobileAds 0 Answers

error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'. Consider storing the value in a temporary variable 3 Answers

Help with this script? Keeps moving my objects around in run-time? 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