Announcement

Collapse
No announcement yet.

How to Make A Ramp. When moving up it slows the player. Down it speeds up player

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Make A Ramp. When moving up it slows the player. Down it speeds up player

    Hello,

    Would anyone know how to make a ramp that, when you are moving up it. Slows down the players walk speed. And when going down the ramp, speeds up the players walk speed.

    If possible, can the speed of the player be adjusted based upon what angle the ramp is? As a minor slope (5degrees) would only effect 10% of the walk speed. And a major slope (35degrees) would effect the walk speed by 80%.

    Thanks

    #2
    There are many ways to handle this. One way would be to keep track of the player velocity, then use the dot product to compare with a stationary vector like up or forward. If the character is grounded, we can then use the dot product to "multiply" how much the player speed is affected. Another way is to make sloped assets use a volume to determine speeds.
    www.dennylindberg.com - My RnD / WIP thread
    Mortal Online 2 - Kitten'd - Guardians of Valor (Android, iOS)

    Comment


      #3
      You could do a line trace from the feet of your player character and use the impact normal returned from the hit information as a scalar to your movement speed.
      DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

      Project Culverin - Open Ended First Person Shooter

      Comment


        #4
        I unfortunately think the volume way would be least effective because of the need to speed up while going down, and slow down while going up.

        I also forgot that this should be done in blueprints (Which I think you all assumed anyways). Is there someone with a screenshot of how it should be done? Right now it's really hard for me to visualize what you are all saying and how it would be able to recognize when it is moving up and moving down the ramp.

        Comment


          #5
          It's easy really, no trace required, if your movement gets updated with a given period, by move event or tick.
          Save your position as oldPosition, compare your currentPosition to it, if you are going up in Z, then you are moving up slope, if you are going down in Z, then you move down slope.
          Since you would also have delta since last update, you can tell by how much you climb up or down.

          It is possible if people can just tap control really quickly(or with a macro) uphill to avoid this type of check to slow down.(what makes ski possible in Tribe1 with macro key binding).
          But the idea is roughly the same, you can even have a "speed up" time before you go on full speed to avoid this type of problem.
          Unreal Engine 4 Game Framework diagram for relation of all major base object types
          Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
          Resident Evil Classic Camera
          RPCs official document, Must Read
          Everything you should know about replication

          Comment


            #6
            Excellent! This sounds about right. I'll try it out later tonight. Thanks Penguin!

            Comment


              #7
              cannot you get the slope value from the character? is not open to BP?

              Comment


                #8
                Originally posted by Bpop View Post
                I unfortunately think the volume way would be least effective because of the need to speed up while going down, and slow down while going up.
                The volume can be used to set different "slope rules", together with the velocity calculations. Maybe it's slippery there. I guess it was an unfinished thought when I mentioned it.
                www.dennylindberg.com - My RnD / WIP thread
                Mortal Online 2 - Kitten'd - Guardians of Valor (Android, iOS)

                Comment


                  #9
                  Originally posted by erWilly View Post
                  cannot you get the slope value from the character? is not open to BP?
                  There are certainly ways to get it. Using a downward trace, you can get the slope of the surface you are on from the impact normal, like I mentioned earlier.
                  DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

                  Project Culverin - Open Ended First Person Shooter

                  Comment

                  Working...
                  X