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 / Getting Angle for height for a slope

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 22nd Apr 2023 17:31 Edited at: 22nd Apr 2023 18:57
Here is some code from here. https://forum.thegamecreators.com/thread/228158

And could someone fix he tital? lol, Angle from Angel ha ha.

This is code I edited from Virtual Nomad and need some help finding out a way to stop my player if there is a wall or high slope. Im guessing I have to find the player Y pos and then limit the movement from there but everything I try stops the player but then moves him into the mesh, it stops the movement for the height but not for the x.

Im sure i am just overthinking this and it is probably simple but I have at least tried. I believe the check for my players Y is before the ObjectRayCast so there is confusion in the program.

This is my only movement code so there is nothing making it act like it is.



Edit,

I even tried finding the GetObjectHeightMapHeight but then got confused.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 23rd Apr 2023 16:39 Edited at: 23rd Apr 2023 16:53
i would avoid using the slope from point a to b to determine if terrain is impassable.
if you're moving directly into/at the slope (ie, perpendicular to it), it would be fine but if you approached the slope at a slight angle (almost parallel) then the difference in elevation from point a to b would be much more gradual.

instead, consider using the Normals of the terrain at point b which are static/don't change no matter your angle of approach.

using your same ray:

...which return values between 0.0 and 1.0 (-1.0 to 1.0 without ABS()).

now say, for example, that anything more than 45 degrees is impassable terrain:

then you could check those normals against your threshold to determine if you can move to point b:


ie, try to keep an eye on the values of NX# & NZ#. if the terrain i'm trying to move to (point b) is impassable then the sky goes red, else green:


you could take this further and say it's impassable if you're going up the hill but not down it by first checking the elevation at point b and comparing it to your current elevation. IE, if down then skip the checks and simply move there.

another usage of the normals might determine how fast you can go up where the steeper the terrain, the slower you move.

pretty handy, eh?

i hope this helps

add: my first time implementing the theory. if i've stated anything wrong above, someone please let us know
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 23rd Apr 2023 20:06
GetObjectRayCastNormalX in theory it makes a lot of sense but in practice my player stops then after a moment goes up the slope anyhow lol.

I think my dream of perfect collision is over at this point and i will just use regular ray casting but I really wanted to use your code because it gets perfect sliding collision.

Thank you for your help and understanding. But i need to just move forward as this collision thing is slowing me down. I will not use a controller, that I do know
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 24th Apr 2023 00:22
Ok so this is what I am doing now, regular sliding collision .

The only thing I hate about it is the third person player never is on the ground so i have to keep the camera close and also camera collision is hard to do. This is why I am looking for other ways.

Login to post a reply

Server time is: 2024-05-04 20:52:44
Your offset time is: 2024-05-04 20:52:44