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 Master_Davicous · May 02, 2017 at 08:45 PM · raycastinputvector3

Given 2 input floats (horizontal, vertical), cast a ray orthogonal to the normal of the surface in direction of input floats?

 Ray walledRay;
 RaycastHit walledHit;
 
 Vector3 walledRayHeading;
 Vector3 walledRayNormal;
 Vector3 walledRayDirection;
 
 walledRayHeading = new Vector3(myTransform.position.x + leftInputVertical, myTransform.position.y, myTransform.position.z - leftInputHorizontal) - myTransform.position;
 walledRayNormal = Vector3.Cross(walledRayHeading, myNormal);
 walledRayDirection = walledRayHeading * (boxCollider.size.x * boxCollider.transform.localScale.x);
 
 walledRay = new Ray(myTransform.position, walledRayDirection);
 
 Debug.DrawRay(myTransform.position, walledRayNormal);

This is what I have so far... Without the cross product in there it works, but only on the Vector3.up normal... When I add the cross product in there, it does some funky stuff and I do not think it is the right solution to this. Vector3.projectonplane is like the opposite of what I'm going for pretty much, haha. Oh, and I forgot to mention but I would like the raycast to be in the direction of the inputs! Thank you if you read this :)

alt text

unityquestionspicture.jpg (123.0 kB)
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 toddisarockstar · May 03, 2017 at 02:07 AM 0
Share

im not sure what you are asking.

are you simply wanting to shoot a ray that remains parallel to whatever angle of the ground you're standing on?

Raycast need an origin and a direction. for the origin you would simply get the players location.

for the direction you would start by getting the angle of the ground you are standing on however you want to do that.

and then change the y as needed probably the players y + input float. but that would only be one input float.

so you need x and z from the ground and change y to whatever ya want

in 3d space there is only three axis. so if you want to absourb the two axis from the ground and change two thats 4. so i would assume you want one of the axis reletive? I would personally set up a child object that can have its local rotation adjused for reference.

0 Replies

· Add your reply
  • Sort: 

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

103 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

Related Questions

Move an object to Input.Touch location 0 Answers

Roll ball towards Vector3 point (Rigidbody) 0 Answers

help with movement along x axis and slow down. please help 1 Answer

problem with vector3.right and up 2 Answers

Problem with converting RaycastHit to Vector3 2 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