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 /
avatar image
0
Question by TheCraze · May 22, 2011 at 09:45 PM · physicsraycastgameobjectsangles

Having Physics.Raycast rotate with the gameObject

I am having issues with trying to get the Raycasts to rotate with the gameObject they are casting from. They basically just need to cast at an 180 and 90 degree angle and rotate with the gameobject.

Any advice would be highly appreciated, thanks.

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 TheCraze · May 22, 2011 at 10:08 PM 0
Share

I still haven't been able to locate a way to do this.

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Owen-Reynolds · May 22, 2011 at 10:22 PM

Raycasts use a point and a direction (or else a Ray, which is built using a point and a direction.) I assume you can find the point -- all you need is the direction.

transform.forward, transform.right and so on, give you the local directions from yourself. So Physics.Raycast(transform.position + Vector3.up, transform,forward); does a raycast starting 1 unit above you, the way you are looking.

The get angles, can use tricks like transform.forward - transform.right*0.2f (aims at a point a little left of you.)

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 simonrcodrington · Mar 31, 2019 at 03:16 AM 0
Share

Transform has properties for up forward and right. You can use the inverse of these to get the opposites like left. Though this might help someone who tries to use .left and nothing appears.

avatar image
0

Answer by Jesvest · Jun 30, 2011 at 11:00 AM

Why cant i see the rest of the answer from Owen Reynolds when i press the more button?

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 3 · Nov 11, 2012 at 10:03 AM 0
Share

thats all there is to it, more simply means more information regarding the post (amount of words, comments)

Also please do not post a question as an answer, rather click add new comment on the bottom right hand of the answer or question. If you continue to do this you will be flagged. Thank you,

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Picking up few different objects 0 Answers

Stop picked up object clipping through walls? 0 Answers

Having a RaycastHit event create a component? 1 Answer

Problem With RayCast 3 Answers

thousands of raycasts in nested for loop 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