Dive Board
-
Crosshair for VR
Crosshair for VR
by Sephiroth on Apr 6th, 2014 23:59 PM
Read somewhere about how a static crosshair isn't suitable for VR since your eyes won't be focusing on the same distance as the crosshair. Might have been the Oculus guide...
So it needs to be dynamic. I wrote a little script that attaches to the 'Dive Camera' that makes a dynamic crosshair by using a raycast to measure the distance ahead and then moves an object to that position. This way the crosshair is always positioned at the distance your eyes are focused.
It also resizes the object so that to the viewer it looks static. It doesn't look like it's moving closer and further away from you, even though it really is.
The effect is quite nice and has no noticable impact on performance. It can also change color if it hovers over certain objects (like an enemy or power up ect).
for the crosshair I'm just using a sphere with the GUI/Text shader that is a child of the 'Dive Camera'. This shader is visible through other objects so isn't obscured if the crosshair is partially buried in another object.
crosshair.js<br /><br />//crossHair game object should use the GUI/Text shader<br />var crossHair : GameObject;<br /><br />function Update () {<br /> crossHairs (); <br />}<br /><br />function crossHairs () {<br /> var crosshairPosition = transform.position;<br /> var crosshairHit: RaycastHit;<br /> var crosshairRay : Ray = new Ray(crosshairPosition, transform.forward);<br /> if (Physics.Raycast(crosshairRay, crosshairHit)) {<br /> var crosshairDistance = crosshairHit.distance;<br /> var crosshairPoint = crosshairHit.point;<br /> }<br /><br /> // increasing the crosshairDistance multiplier increases the size of the crosshair<br /> crossHair.transform.localScale = new Vector3(crosshairDistance*0.005, crosshairDistance*0.005, crosshairDistance*0.005);<br /> crossHair.transform.position = crosshairPoint;<br /> <br /> // Change 'Enemy' to the name of the object you would like to make the crosshair change color<br /> if (crosshairHit.collider.name == "Enemy") {<br /> crossHair.renderer.material.color = Color.red;<br /> } else {<br /> crossHair.renderer.material.color = Color.white;<br /> }<br /> <br />}<br /><br /><br />
Example (the little white dot in the center) :
Short Distance
Long Distance :
Sephiroth
Posts: 45
Joined: 17.03.2014
Re: Crosshair for VR
by hikitax845 on May 14th, 2023 11:43 AM
Interesting and amazing how your post is! It Is Useful and helpful for me That I like it very much, and I am looking forward to Hearing from your next.. World of Woodcraft
hikitax845
Posts: 1484
Joined: 29.09.2022
Re: Crosshair for VR
by hikitax845 on May 21st, 2023 15:53 PM
Good job for publishing this kind of beneficial web site. Your online log isn't only useful but it is additionally really creative too. ponizej 2
hikitax845
Posts: 1484
Joined: 29.09.2022
Re: Crosshair for VR
by hikitax845 on May 27th, 2023 12:39 PM
Thanks because you have been willing to talk about information with us. we shall always appreciate all you have done here because I am aware you're very focused on our. letyshops kod polecajacy
hikitax845
Posts: 1484
Joined: 29.09.2022
Re: Crosshair for VR
by jacker on Jun 18th, 2023 11:53 AM
共度的高品質時光創造了珍貴的回憶,加強了情感連結。正确使用犀利士CIALIS犀利士常見的副作用可能包括頭痛、消化不良、背痛、肌肉疼痛和臉紅。 Cialimall.com
jacker
Posts: 30792
Joined: 27.10.2022
Re: Crosshair for VR
by jacker on Jun 19th, 2023 10:18 AM
A prescription for Cialis ensures that users are aware of potential drug interactions and their implications. 透過處方獲得犀利士確保使用者了解潛在藥物相互作用及其影響。 犀利士台灣官網
jacker
Posts: 30792
Joined: 27.10.2022
Re: Crosshair for VR
by jacker on Jun 20th, 2023 08:28 AM
The a truly great place That i experienced owing to publish it all. The chances of what precisely I want to observe pray during near future you can expect to keep going meant for posting an extremely good place. puerto morelos all inclusive
jacker
Posts: 30792
Joined: 27.10.2022
Re: Crosshair for VR
by asdfghjk on Dec 31st, 2023 07:06 AM
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. ทางเข้า ufabet มือถือ
asdfghjk
Posts: 786
Joined: 04.12.2023
Re: Crosshair for VR
by asdfghjk on Dec 31st, 2023 08:15 AM
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. ufabet เว็บหลัก ทางเข้า
asdfghjk
Posts: 786
Joined: 04.12.2023
Re: Crosshair for VR
by asdfghjk on Dec 31st, 2023 08:35 AM
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. วิธีสมัคร ufabet
asdfghjk
Posts: 786
Joined: 04.12.2023
STATISTICS
Total posts: 164147
Total topics: 39939
Total members: 43835
Newest member: Daniel G.
Lernen Sie die Durovis Dive Familie kennen und verwandeln Sie Ihr Mobilgerät in ein VR-Headset. Erleben Sie Spiele und 360° Videos in VR auf Ihrem Smartphone oder Tablet.