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.

Newcomers AppGameKit Corner / [SOLVED] Trying to get y coordinate from terrain - raycast not hitting?

Author
Message
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 10th Jul 2018 20:33 Edited at: 10th Jul 2018 20:41
Hi,

Not sure why my terrain is not returning a hit when I am clearly directly above it. I have tried many different tweaks, and nothing returns a hit. Really at a loss here. Would appreciate any help.



edit: Forgot to mention - I have tried using objects straight from blender, creating a plane and creating objects from heightmaps.

If I make the endY# negative, I get a hit, but the coordinates do no line up with where my character is. Plus the Y coordinate is incorrect. I could be under the terrain, and according to the y# return its under my character...

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

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Jul 2018 22:05 Edited at: 10th Jul 2018 22:06
This post has been marked by the post author as the answer.
Its because your ray makes no sense at all. the start point and the end point arent to logical. Why are you adding the camera position to the players position? Why are you simply multiplying the start position by 800 to get the end?

Your start position and end position for your ray dont look to make any sense??

Are you trying to find the height below the player object?
Start of the ray would be the player object location x,y,z and the end of the ray would be x,y-1000,z.....thats a vector that points straight downwards along the y axis

You can also use GetObjectHeightMapHeight() and just pass in x and z coords.


Or are you trying to find the y position on the terrain that the camera is currently looking at?
In which case...start at the camera position and add the direction the camera is pointing in....dont just multiply by 800.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 10th Jul 2018 22:41
Thanks Bengismo,

I took a break came back, and was able to think about wth I was doing. I got it figured out now. Just need to prevent the camera from going under the terrain. Thank you.

Login to post a reply

Server time is: 2024-03-29 14:05:56
Your offset time is: 2024-03-29 14:05:56