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 Haobo38 · Oct 19, 2021 at 08:30 AM · cameravreventsystemphysics.raycast

event triggered by the wrong camera

after the override of input in order to use the htc vive controllers :

 public class VRCanvasInput : BaseInput
 {
 
     public Camera eventCamera = null;
     public SteamVR_Input_Sources m_TargetSource;
     public SteamVR_Action_Boolean m_ClickAction;
     protected override void Awake()
     {
         GetComponent<BaseInputModule>().inputOverride = this;
        
     }
     public override bool mousePresent
     {
         get
         {
             return true;
         }
     }
 
     public override bool GetMouseButton(int button)
     {
         return m_ClickAction.GetState(m_TargetSource);
     }
 
     public override bool GetMouseButtonDown(int button)
     {
 
         return m_ClickAction.GetStateDown(m_TargetSource);
     }   
     public override bool GetMouseButtonUp(int button)
     {
         return m_ClickAction.GetStateUp(m_TargetSource);
     }
     public override Vector2 mousePosition
     {
         get
         {
              return new Vector2(eventCamera.pixelWidth / 2, eventCamera.pixelHeight / 2);
         }
     }
 }

I want to create a physics pointer attaching the following script :

 public class PhyCamPointer : MonoBehaviour
 {
 
     public float defaultLength = 3.0f;
     private LineRenderer lineRenderer = null;
     public GameObject m_Dot;
     public Camera m_Camera= null;
 
     private void Awake()
     {
         lineRenderer = GetComponent<LineRenderer>();
         m_Camera = GetComponent<Camera>();
 
     }
 
     private void Update()
     {
         UpdataLength();
     }
 
     public Camera GetCamera()
     {
         if (m_Camera == null)
             print("failded to get camera");
         return m_Camera;
     }
 
 
     public Vector3 GetDotPosition()
     {
         return CalculateEnd();
     }
     private void UpdataLength()
     {
         lineRenderer.SetPosition(0, transform.position);
         lineRenderer.SetPosition(1, CalculateEnd());
         //print("laiser end dot position" + CalculateEnd().x + CalculateEnd().y);
     }
 
     private Vector3 CalculateEnd()
     {
         RaycastHit hit = CreateForwardRaycast();
         Vector3 endPosition = DefaultEnd(defaultLength);
         if (hit.collider)
             endPosition = hit.point;
         m_Dot.transform.position = endPosition;
         return endPosition;
     }
     private RaycastHit CreateForwardRaycast()
     {
         RaycastHit hit;
         Ray ray = new Ray(transform.position, transform.forward);
         Physics.Raycast(ray, out hit, defaultLength);
         return hit;
     }
 
     private Vector3 DefaultEnd(float length)
     {
         return transform.position + (transform.forward * length);
     }
 
 }


for the eventSystem and physicsPointer (child of right controller )

alt text

alt text

after such configuration, when i lanch the project, the ray is always casted from the camera of the cameraRig( the prefab in steamVR) which means i cant select the objects with the controller but with the headset ( like a look select but not a controller select ) can someone tell me how can i set it to the right camera. Thanks a lot

capture.png (65.6 kB)
eventsystem.png (61.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

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

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

HUD wont show with Cardboard 0 Answers

How to use Target Eye Unity 5.2.2p1? 0 Answers

Google cardboard - Wrong cameras? 0 Answers

Steam VR second untracked camera on display 2 0 Answers

Making configuration changes on user-input 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