Jump to content

Terrain Slope Problem?


Recommended Posts

13 hours ago, Mythros said:

Because @satguru's demo is what I'm looking for.

@satguru I tried to figure out checking if the player is climbing up the slope & can't seem to figure it out. Here's my rendition : 


Lines 298 - 312


oldposy = this.avatar.position.y;
	                    this.moveVector.copyFromFloats(0, -this.downDist, 0);
	                    posy = this.avatar.position.y;
	                    if ( posy > oldposy )
	                        console.log ( 'YAY!' );

wrong place to put the code. This code is executed when the av is falling down.



Link to comment
Share on other sites

20 hours ago, jerome said:

From the beginning of this post, I don't get why you don't use the BJS provided GroundMesh class what provides the ground altitude AND the ground normal at any coordinates (x, z) in the world ...

example : http://jerome.bousquie.fr/BJS/demos/getHeightAtCoordinates.html

what do you do if the mesh is not moving on ground. In my demo how would you handle moving on the planks?

Link to comment
Share on other sites


Sorry I was away and also wasn't getting any notifications of your messages.

If instead of climbing up the slope and then sliding down when stationary, you want to prevent the player from climbing up the slope at all then yes that should be possible. Currently I check slope only when new y is less than old y but we can do that at other times too. Also instead of just one slope limit we can take two limits- min and max slope limits. If slope between min and max then  player can climb but will slide down if stationary , if more than max then player won't be able to climb at all. Will work on that when I have some time which probably won't be any time soon. Maybe an exercise for you ? :)

Link to comment
Share on other sites

Poor Mythros.  *sigh*  How are we going to set you on the path of righteousness?  :)

You asked... "Why is there no demo that shows how to do this basic player movement with changing terrain slopes and sliding/blocking?" 

How about this answer.  "Because it is not an easy task, and everyone wants theirs to act differently than another." 

There's no standard way of doing these calculations, and accelerated slidings.  You must code it... to make it act as you wish.  Console.log everything.  Learn how satguru's system works, and adapt it to work for you.  You seem to be against "hacking it out for yourself"... and I'm kindly asking WHY? 

This terrain can be ANY rez/subdivs, so maybe the slope changes every 20 units walked, and maybe it changes every .1 units walked.  Needless to say, current slope needs to be calculated constantly... even while a slide or a blockage is happening.

Sliding?  Without using a physics engine/impostor, YOU must move the player yourself... to slide.  YOU must tell it to slide (unless you can convince someone to write your code FOR you).  Sliding is a movement of x, y, and z... all at the same time.  Y value must be constantly accelerated per the continuously-monitored slope-angle beneath the constantly-sliding player's feet.  WOW!

Blocking?  YOU must tell it to ignore movement commands in directions where angle > 30 degrees.

AND... you haven't even STARTED addressing momentum.  Myth... do you know what switchbacks, are?  Sure you do.  The slope COULD BE > 30 degrees, but if player uses diagonal switchback method, maybe they can still climb the hill.  It all depends upon whether/not you will allow "strafe" movement... side-stepping, and whether/not side-sliding is possible.  AND... are you going to use the same rules for side-sliding... as you are for forward/backward sliding/blocking?  I wouldn't, if I were you.  Humans can hold-place on steeper-angled hills... if they are standing sideways (using shoe/foot/ski edges).

And, can the player make the turn at the end of each switchback leg... without accidentally back-sliding down the hill?  There are no flat roads on our BJS terrain.  SO, when player makes a turn at the end of a switchback leg, he/she will have a "moment"-of... facing straight-up a > 30 deg angle, and the code says "slide backwards" if that happens, so the player is not able to make the switchback turn. 

With me?  I hope so.  What you ask-for.... is very complicated.  There are TWO directions of movement that you must always "sum".  Sliding direction, and wanted movement direction. 

CAN a player be walking forward JUST FINE (no sliding forward or backward happening)... yet be occasionally or continuously side-sliding?

If a player walks down a slope at a diagonal, could there be SOME sideways-sliding and SOME forward-sliding?

If a player slides down a LONG slope, will you want to add acceleration?  If the slope suddenly changes from > 30 degs.... to 28 degrees... will the player's mass, friction, momentum (inertia)... make him/her slide MORE... even on the 28 degree terrain?  He/She will have quite a bit of speed. 

What if a logging truck accidentally fell-off one of those switchback roads?  Do you think the truck would stop when it landed on the switchback road below?  Unlikely.  It's speed/momentum would likely make it go all the way to the bottom, ignoring ALL < 30 degree terrain on the way.  You have SO MANY THINGS to take into consideration... for this project.  Using physics engine/impostor... would handle MOST of your hassles.  But... "walking" a physics impostor... is known to be a challenge, too.  IT will ALSO cause you to do special and deep coding.

This is a sufficiently complicated project... that you MIGHT want to avoid "hounding" anyone, about it. Not saying that you have done that, but, you know, tact and all. 

So again, why don't you want to simply "grind out the solution"?  Don't you LOVE programming and console.logging other people's code/variables, and watch the numbers, and learn how things are done, so you can borrow those techniques for other projects?  How can you NOT love doing that?  It's wonderful, and it has a self-satisfaction quotient the size of the moon.  :)  Ya got a powerful robotics system in JS, ya got a geometry playground that listens to JS... just tell it what ya want it to do.  It takes orders GREAT.

Was I kind, in this post?  I hope I didn't hurt your feelings.

Link to comment
Share on other sites

23 hours ago, adam said:

Are you able to detect the slope of the terrain?  If not, work on that

Yep, yep, and yep.  :)  Ideally, both angle and direction of the slope, near-continuously monitored while player is moving around.  Place an arrow thru the player, and make it point up/down the current slope angle/direction.  Make the arrow change colors when angle > 30 degrees.  Coooooool.  Great little test bed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...