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 Mar 16, 2014 at 06:03 PM by z3nth10n for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by z3nth10n · Jan 21, 2014 at 05:02 PM · rotationraycastsphere

Infinite Raycast?

Hi,

well I know that it is impossible (because the skybox is only a texture, no a solid thing), but I use a sphere that follows the player (so the player is inside it) and the problem is that inside it nothing is detected...

 Ray ray = Camera.main.ScreenPointToRay (new Vector3(Screen.width/2,Screen.height/2,0));
 RaycastHit hit;
 if (Physics.Raycast (ray, out hit)) {
     holdedItem.transform.LookAt(hit.point);
     holdedItem.transform.rotation *= Quaternion.Euler(Slots.HotBarSlots[selectedSlot].FcustomRotation);
 }    

That code is for rotate the current object (in the Inventory, but this is not relevant, the only things important is say that the current object is near the camera, so it can be showed by the camera behind him) to the area where the player is looking (exactly on the center of the screen)

But when I look to the sky the rotation return zero (it's normal because the sky isn't solid), but as I said before I use a sphere, that is not detected... I don't know why... D:

So, how can I make the sphere solid in its inside part for make a "Infinite" Raycast system?

Thanks in advance. Bye.

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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by ArkaneX · Jan 21, 2014 at 05:51 PM

Your sphere is not detected, because Raycast can't detect colliders from the inside. There is a short info about this in the official docs.

Comment
Add comment · Show 3 · 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 z3nth10n · Jan 21, 2014 at 07:31 PM 0
Share

Well thanks, but I need solutions... Is there another way to do this? $$anonymous$$aybe not with a Raycast, but a code that does the following thing: Rotate the current object (because when I look down the weapon that I have on the scene it's frontal face is looking fowards, and I want that face looks to the ground), by following the mouse, or a point of the screen.. I don't what can do that, so... Can you help me with this? Thanks. =3

avatar image ArkaneX · Jan 21, 2014 at 11:33 PM 0
Share

If I understand you correctly, and the raycasting is required only to find the point where your character is looking, then you can find this point using:

 var point = Camera.main.transform.position + Camera.main.transform.forward * 100f;

I used 100f as an example only, but it should be ok if the rotating object is near the camera. With this solution you don't need any sphere surrounding the player.

avatar image z3nth10n · Jan 22, 2014 at 06:40 AM 0
Share

I see some shooters, and I think that the weapon is inside the camera, so when the player look to another part the weapon moves and rotates with the camera, I have some shooters, I will check that later, and I will say you. :P

Follow this Question

Answers Answers and Comments

19 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

Related Questions

raycast to determine pivot 1 Answer

Pointing object at mouse using raycast only works when object is center screen. 2 Answers

mouse cursor between two rays 3 Answers

Setting object Rotation to RayCast line 1 Answer

Make an object translate/raycast a certain way disregarding it's rotation 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