Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Check if player is moving backwards

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

    Check if player is moving backwards

    I want to disable sprint for my character if he's moving backwards. Is there an in-built way of doing this instead of coding the calculation myself?

    #2
    There's no function that I know but the calculation is really simple. You just need to check whether the direction the character is moving is the "same" as the direction it is facing. You can use the dot product for that.

    Code:
    function bool IsMovingBackwards()
    {
    	return Pawn.Velocity dot vector(Pawn.Rotation) < 0.0f;
    }

    Comment


      #3
      Thanks dude

      Comment


        #4
        The trouble here is that I'd have to check every tick. I'd like to change the GBA_Backward in the config to call my own move backward function.

        This would simply call the same command as it would usually, but add my own logic along side.

        The trouble I'm having is how do I call "Axis aBaseY Speed=-1.0" from unrealscript? This is what currently exists in DefaultInput.ini

        Code:
        .Bindings=(Name="GBA_Backward",Command="Axis aBaseY Speed=-1.0")

        Comment


          #5
          Why not use an exec function and just set the groundspeed var to whatever speed you prefer

          Comment


            #6
            Originally posted by coldscooter View Post
            The trouble here is that I'd have to check every tick. I'd like to change the GBA_Backward in the config to call my own move backward function.

            This would simply call the same command as it would usually, but add my own logic along side.

            The trouble I'm having is how do I call "Axis aBaseY Speed=-1.0" from unrealscript? This is what currently exists in DefaultInput.ini

            Code:
            .Bindings=(Name="GBA_Backward",Command="Axis aBaseY Speed=-1.0")
            Axis aBaseY refers to PlayerInput::aBaseY. Could be that there is already a variable that you can use: PlayerInput::bWasBack which means you don't really need to do anything other than use it straight away. It is set in PlayerInput::CatchDoubleClickInput called from PlayerInput::PlayerInput which is called by the engine to allow "postprocessing" of the input.
            Otherwise you should be able to bind another input to the same command like so (this is similar to how the spacebar is used for jumping and adding aUp input.
            Code:
            .Bindings=(Name="GBA_Backward",Command="Axis aBaseY Speed=-1.0 | BackwardsMovementFunction")

            Comment


              #7
              @UnrealEverything Thanks for the response. That's actually what i've ended up doing. Works fine, but is exploitable, meaning that players could remove BackwardsMovementFunction from their config .ini file.

              Comment

              Working...
              X