Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 conguerror · Oct 26, 2020 at 10:34 AM · vector3raycastingoffset

Raycast constant v shape in front of player on any rotation

alt text

Hey guys so I need to make a raycast with constant v shape in front of player and so that it raycast horizontally and doesn't intersect with player(just like in pic 1 but on any rotation, I need to place hands according to those rays). Problem is that whenever I turn the player rays do not turn with it(I make rays out of the child empty object). alt text

Code:

 Physics.Raycast(IKRayOrigin.transform.position + originOffset, -IKRayOrigin.transform.up + leftVector, out L_hit, ledgeScript.grabHeight)
 
 Physics.Raycast(IKRayOrigin.transform.position + originOffset, -IKRayOrigin.transform.up + rightVector, out R_hit, ledgeScript.grabHeight)

Ray Offset values:

left vector: x: -0.47ff y:0f z:0.23

right vector 0.35f,0,0.23

Empty game object(origin local position): -0.108,2.03,0.366

capture.jpg (19.1 kB)
2.jpg (22.3 kB)
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

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

Answer by Duckocide · Oct 26, 2020 at 10:49 AM

I'm assuming the blue diamond / cube is attached as a child to the character.

If so a really quick way of getting the right direction out of the blue diamond / cube is to add two empty game objects in turn to it. Orientate those objects transforms so the z-axis (blue) is point the way you want each ray to go. Then use (of those two gameobjects) transform.forward for the ray direction.

I think the should work.

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 conguerror · Oct 26, 2020 at 11:01 AM 0
Share

I will try it out, thanks for answer. Any other suggestions?

avatar image Duckocide conguerror · Oct 26, 2020 at 11:06 AM 0
Share

You can do the rotational math based on the player, but I think provided the blue cube game object is attached to the character (to pick up transform position / rotation) and in turn the ray direction empty gameobjects is the easiest way. The math will be similar to what unity is doing with the transforms anyway.

It's also very visual in the editor (gizmo's and option to attach visual debug shapes to those empty transforms).

avatar image conguerror Duckocide · Oct 26, 2020 at 11:20 AM 0
Share

I hate choosing the hard way, anyway

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

176 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Only One LineRenderer Renders 0 Answers

How to offset Pointer in EventSystem Interface 0 Answers

Snapping to Object Forward Axis 0 Answers

Object not following parent position when parent rotation is locked,Unable to move an object with its parent when rotation is locked 0 Answers

Boxcast vs Raycast Oddities 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