Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] raycast forward facing in front of camera?

Author
Message
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 6th Jan 2019 02:48
Anyone know the calculation for objectraycast endx, endy and endz?

basically this: https://answers.unity.com/questions/437537/how-can-i-make-a-raycast-go-in-the-direction-the-c.html

Any help appreciated!

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Jan 2019 03:34 Edited at: 6th Jan 2019 05:11
Note that you have to set the distance. You could convert it into a raycast that checks for collision in your scene.
In which case, you could make the depth 1, calculate the first point, then a very large number, calculate the second point. Then use those two points to cast your ray

Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 6th Jan 2019 10:04 Edited at: 6th Jan 2019 10:10
This post has been marked by the post author as the answer.
You are right!
...But I have already found the solution and was going to report it...
I was even messing with quant...

Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 7th Jan 2019 02:13
To cast in the direction of the camera easily, with almost no performance impact, just do this.

Get the camera x, y and z position
Move camera local z by however far you want
Gets it's position again
Move it back to the original position and you have two perfect sets of ray cast coords
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 7th Jan 2019 03:25
Haha. Very clever

Login to post a reply

Server time is: 2024-04-26 06:51:27
Your offset time is: 2024-04-26 06:51:27