Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #22 from Nick-Pearson/Ragdoll_Inputs
Browse files Browse the repository at this point in the history
Converted ragdoll inputs from Blueprint to C++
  • Loading branch information
Nick-Pearson authored Nov 16, 2017
2 parents 23049c9 + 4e41e63 commit a801e20
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 37 deletions.
28 changes: 14 additions & 14 deletions ParkourGame/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum

[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/ThirdPersonCPP/Maps/entryMap.entryMap
LocalMapOptions=
TransitionMap=/Game/ThirdPersonCPP/Maps/transitionMap.transitionMap
bUseSplitscreen=True
TwoPlayerSplitscreenLayout=Horizontal
ThreePlayerSplitscreenLayout=FavorTop
bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/Engine.GameInstance
GameDefaultMap=/Game/ThirdPersonCPP/Maps/entryMap.entryMap
ServerDefaultMap=/Game/ThirdPersonCPP/Maps/testLevel.testLevel
GlobalDefaultGameMode=/Script/ParkourGame.ParkourGameGameMode
GlobalDefaultServerGameMode=None

[/Script/Engine.PhysicsSettings]
DefaultGravityZ=-980.000000
DefaultTerminalVelocity=4000.000000
Expand Down Expand Up @@ -55,18 +69,4 @@ AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10

[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/ThirdPersonCPP/Maps/entryMap.entryMap
LocalMapOptions=
TransitionMap=/Game/ThirdPersonCPP/Maps/transitionMap.transitionMap
bUseSplitscreen=True
TwoPlayerSplitscreenLayout=Horizontal
ThreePlayerSplitscreenLayout=FavorTop
bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/Engine.GameInstance
GameDefaultMap=/Game/ThirdPersonCPP/Maps/entryMap.entryMap
ServerDefaultMap=/Game/ThirdPersonCPP/Maps/testLevel.testLevel
GlobalDefaultGameMode=/Script/ParkourGame.ParkourGameGameMode
GlobalDefaultServerGameMode=None


136 changes: 115 additions & 21 deletions ParkourGame/Config/DefaultInput.ini
Original file line number Diff line number Diff line change
@@ -1,24 +1,118 @@
[/Script/Engine.InputSettings]
+ActionMappings=(ActionName="Jump", Key=SpaceBar)
+ActionMappings=(ActionName="Jump", Key=Gamepad_FaceButton_Bottom)

+AxisMappings=(AxisName="MoveForward", Key=W, Scale=1.f)
+AxisMappings=(AxisName="MoveForward", Key=S, Scale=-1.f)
+AxisMappings=(AxisName="MoveForward", Key=Up, Scale=1.f)
+AxisMappings=(AxisName="MoveForward", Key=Down, Scale=-1.f)
+AxisMappings=(AxisName="MoveForward", Key=Gamepad_LeftY, Scale=1.f)

+AxisMappings=(AxisName="MoveRight", Key=A, Scale=-1.f)
+AxisMappings=(AxisName="MoveRight", Key=D, Scale=1.f)
+AxisMappings=(AxisName="MoveRight", Key=Gamepad_LeftX, Scale=1.f)

+AxisMappings=(AxisName="TurnRate", Key=Gamepad_RightX, Scale=1.f)
+AxisMappings=(AxisName="TurnRate", Key=Left, Scale=-1.f)
+AxisMappings=(AxisName="TurnRate", Key=Right, Scale=1.f)
+AxisMappings=(AxisName="Turn", Key=MouseX, Scale=1.f)
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
FOVScale=0.011110
DoubleClickTime=0.200000
bCaptureMouseOnLaunch=True
DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
bDefaultViewportMouseLock=False
DefaultViewportMouseLockMode=LockOnCapture
-ActionMappings=(ActionName="Jump",Key=SpaceBar,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="Jump",Key=Gamepad_FaceButton_Bottom,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="ResetVR",Key=R,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="ResetVR",Key=MotionController_Left_Grip1,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollBody",Key=Zero,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollArmR",Key=One,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollArmL",Key=Two,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollLegR",Key=Three,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollLegL",Key=Four,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="RagdollTorso",Key=None,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="Jump",Key=SpaceBar,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="Jump",Key=Gamepad_FaceButton_Bottom,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="ResetVR",Key=R,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="ResetVR",Key=MotionController_Left_Grip1,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollBody",Key=Zero,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollArmR",Key=One,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollArmL",Key=Two,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollLegR",Key=Three,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollLegL",Key=Four,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollTorso",Key=Five,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="RagdollLegs",Key=Six,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-AxisMappings=(AxisName="MoveForward",Key=W,Scale=1.000000)
-AxisMappings=(AxisName="MoveForward",Key=S,Scale=-1.000000)
-AxisMappings=(AxisName="MoveForward",Key=Up,Scale=1.000000)
-AxisMappings=(AxisName="MoveForward",Key=Down,Scale=-1.000000)
-AxisMappings=(AxisName="MoveForward",Key=Gamepad_LeftY,Scale=1.000000)
-AxisMappings=(AxisName="MoveRight",Key=A,Scale=-1.000000)
-AxisMappings=(AxisName="MoveRight",Key=D,Scale=1.000000)
-AxisMappings=(AxisName="MoveRight",Key=Gamepad_LeftX,Scale=1.000000)
-AxisMappings=(AxisName="TurnRate",Key=Gamepad_RightX,Scale=1.000000)
-AxisMappings=(AxisName="TurnRate",Key=Left,Scale=-1.000000)
-AxisMappings=(AxisName="TurnRate",Key=Right,Scale=1.000000)
-AxisMappings=(AxisName="Turn",Key=MouseX,Scale=1.000000)
-AxisMappings=(AxisName="LookUpRate",Key=Gamepad_RightY,Scale=1.000000)
-AxisMappings=(AxisName="LookUp",Key=MouseY,Scale=-1.000000)
+AxisMappings=(AxisName="MoveForward",Key=W,Scale=1.000000)
+AxisMappings=(AxisName="MoveForward",Key=S,Scale=-1.000000)
+AxisMappings=(AxisName="MoveForward",Key=Up,Scale=1.000000)
+AxisMappings=(AxisName="MoveForward",Key=Down,Scale=-1.000000)
+AxisMappings=(AxisName="MoveForward",Key=Gamepad_LeftY,Scale=1.000000)
+AxisMappings=(AxisName="MoveRight",Key=A,Scale=-1.000000)
+AxisMappings=(AxisName="MoveRight",Key=D,Scale=1.000000)
+AxisMappings=(AxisName="MoveRight",Key=Gamepad_LeftX,Scale=1.000000)
+AxisMappings=(AxisName="TurnRate",Key=Gamepad_RightX,Scale=1.000000)
+AxisMappings=(AxisName="TurnRate",Key=Left,Scale=-1.000000)
+AxisMappings=(AxisName="TurnRate",Key=Right,Scale=1.000000)
+AxisMappings=(AxisName="Turn",Key=MouseX,Scale=1.000000)
+AxisMappings=(AxisName="LookUpRate",Key=Gamepad_RightY,Scale=1.000000)
+AxisMappings=(AxisName="LookUp",Key=MouseY,Scale=-1.000000)
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde

+AxisMappings=(AxisName="LookUpRate", Key=Gamepad_RightY, Scale=1.f)
+AxisMappings=(AxisName="LookUp", Key=MouseY, Scale=-1.f)

+ActionMappings=(ActionName="ResetVR", Key=R)
+ActionMappings=(ActionName="ResetVR",Key=MotionController_Left_Grip1,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
Git LFS file not shown
52 changes: 52 additions & 0 deletions ParkourGame/Source/ParkourGame/ParkourGameCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ void AParkourGameCharacter::SetupPlayerInputComponent(class UInputComponent* Pla

// VR headset functionality
PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &AParkourGameCharacter::OnResetVR);

// Ragdoll controls
PlayerInputComponent->BindAction("RagdollBody", IE_Pressed, this, &AParkourGameCharacter::RagdollBody);
PlayerInputComponent->BindAction("RagdollArmR", IE_Pressed, this, &AParkourGameCharacter::RagdollArmR);
PlayerInputComponent->BindAction("RagdollArmL", IE_Pressed, this, &AParkourGameCharacter::RagdollArmL);
PlayerInputComponent->BindAction("RagdollLegR", IE_Pressed, this, &AParkourGameCharacter::RagdollLegR);
PlayerInputComponent->BindAction("RagdollLegL", IE_Pressed, this, &AParkourGameCharacter::RagdollLegL);
PlayerInputComponent->BindAction("RagdollTorso", IE_Pressed, this, &AParkourGameCharacter::RagdollTorso);
PlayerInputComponent->BindAction("RagdollLegs", IE_Pressed, this, &AParkourGameCharacter::RagdollLegs);
}


Expand Down Expand Up @@ -138,3 +147,46 @@ void AParkourGameCharacter::MoveRight(float Value)
AddMovementInput(Direction, Value);
}
}

void AParkourGameCharacter::RagdollBody()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetSimulatePhysics(true);
}

void AParkourGameCharacter::RagdollArmR()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("upperarm_r", true, true);
}

void AParkourGameCharacter::RagdollArmL()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("upperarm_l", true, true);
}

void AParkourGameCharacter::RagdollLegR()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("thigh_r", true, true);
}

void AParkourGameCharacter::RagdollLegL()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("thigh_l", true, true);
}

void AParkourGameCharacter::RagdollTorso()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("spine_01", true, true);
}

void AParkourGameCharacter::RagdollLegs()
{
USkeletalMeshComponent* PlayerMesh = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()));
PlayerMesh->SetAllBodiesBelowSimulatePhysics("thigh_r", true, true);
PlayerMesh->SetAllBodiesBelowSimulatePhysics("thigh_l", true, true);
}
14 changes: 14 additions & 0 deletions ParkourGame/Source/ParkourGame/ParkourGameCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ class AParkourGameCharacter : public ACharacter
/** Handler for when a touch input stops. */
void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);

void RagdollBody();

void RagdollArmR();

void RagdollArmL();

void RagdollLegR();

void RagdollLegL();

void RagdollTorso();

void RagdollLegs();

protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
Expand Down

0 comments on commit a801e20

Please sign in to comment.