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 / Advice on walking on slopes? How to keep players from finding "holes"

Author
Message
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Mar 2019 16:49
So, it seems no matter what I do, there will be "holes" in the steepness test that the character can find if I am persistent enough.

What are some tricks that I could do to prevent this? More often than not it just leads me to getting stuck on the terrain, and having a frustrating time to find my way back down the slope.

The only thing I can think of is to create invisible barriers or use rocks.

Has anyone had this problem, and can give any advice?
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Mar 2019 17:16 Edited at: 15th Mar 2019 17:27
Can you explain the kind of map and collision you are using?....collision is what I like the most
I'm not a grumpy grandpa
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Mar 2019 17:32
Collision test is what I use.

I've included a short video. The biggest problem is when he turns, it reduces the slope so its easy to bypass. Thanks.




chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Mar 2019 17:50
I can see what you meant....so you want the player can go up n down the slopes but stop if theres an object rigth?
I'm not a grumpy grandpa
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Mar 2019 17:57
No. I have that part figured out.

The problem is the character can escape the slope test by turning, therefore, finding a lower slope. It leads the player getting stuck, or having a frustrating time finding their way back down.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Mar 2019 17:59
Ok...I anderstood... what about puting an invisible sensor just in front of your player to check if you can climb ?
I'm not a grumpy grandpa
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 15th Mar 2019 18:48
I have slopes in my 2D game but perhaps the conceptual approach might help...

I sense the height of the ground at the front snd back of the player (I fact where they would be if the next move is permissible). If the height is lower, they need to fall to this new height. If it’s higher but not too high a difference then the character climbs. If the height change is above a threshold (too steep to climb... eg a vertical wall) the I simply block the movement in that direction. In reality it’s slightly more complex but does this help?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 15th Mar 2019 19:19
i think you are meaning for the player to be stopped by steep slopes (up or down)
the problem is if the player approaches the slope at an angle the slope is "seen" as less steep and so the player can walk up / down it but they may get stuck by doing so?
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Mar 2019 20:03 Edited at: 15th Mar 2019 20:07
Exactly, smallg.

DavidAGK,

That is my exact approach I am doing now. I test the current position, then I test where the player will move to(with a slight increase due to FPS). The player's speed is then adjusted by the slope to eventually a speed of zero. Then I take the players "would be" position and find the y-coord via raycast.



But, in some areas the player can find their way up, if they are persistent enough. Hopefully, that makes sense?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 15th Mar 2019 23:04 Edited at: 15th Mar 2019 23:07
You can calculate the terrains normal and the players movement vector... a dot product will then give you something between one and zero.
One means it either goes down or up the hill and zero(player vector is perpendicular to terrains normal) means the terrain is flat in relation to your players movement.
Then you just reduce the movement speed regarding this value.
You could also make him slower going up and faster going down if you get the differences sign in combination with the dot product.

I explained it a bit complicated i guess, but its easy actually.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Mar 2019 23:15 Edited at: 15th Mar 2019 23:23
I think you probably need a walkable area map.
It would be handy down the track i think

Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 16th Mar 2019 00:48
Ah, both excellent ideas, and something I will need to research.

Thank you, both.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 16th Mar 2019 01:37
Janbo, is the player's movement vector the next step location? Or is it the change in x,y,z?

I am a little confused by that term. I haven't quite wrapped my head around what a vector is.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Mar 2019 02:10 Edited at: 16th Mar 2019 02:11
A vector is the x/y/z distance from it's current position that you intend to move

d.x = next.x - current.x
d.y = next.y - current.y
d.z = next.z - current.z

You will probably need to normalize it. I know there are functions around the board that will do this

AGK has some functions that make it easy

man = CreateVector3(d.x, d.y, d.z)
dot = GetVector3Dot(man, hill)

I'm not sure you can get the hill normal though.
How are you going to know which poly is part of the hill?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 16th Mar 2019 11:07 Edited at: 16th Mar 2019 11:20
Quote: "Janbo, is the player's movement vector the next step location? Or is it the change in x,y,z?"

Sounds like its the same ? Take delta from next step and actual player position.(like blinkok)
Anyway you don't want y set it to zero.

And you don't need to normalize it as the dot product doesn't care.

Quote: "How are you going to know which poly is part of the hill?"

You can read the vertices from memblock and then just take the nearest to the player or like a grid.
Calculate the nomal with their neighbours.

Can't you get the hills nomal with raycasts ?
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 16th Mar 2019 17:12
So, the dot product method runs into the same problem of just finding the slope. If the character turns the slope will be lessened.

What was needed was using the cross product. This produces the desired results. I used this article as a guide.

With the below code, I can just use the y value of the SlopeVector to limit movement. Or I could use the angle#. These both produce the desired results no matter which direction the player turns, so he can't cheat his way up a steep slope.

Login to post a reply

Server time is: 2024-03-28 10:06:10
Your offset time is: 2024-03-28 10:06:10