├── Config ├── DefaultEditor.ini ├── DefaultEditorPerProjectUserSettings.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content ├── Geometry │ └── Meshes │ │ ├── 1M_Cube.uasset │ │ ├── 1M_Cube_Chamfer.uasset │ │ ├── CubeMaterial.uasset │ │ └── TemplateFloor.uasset ├── Mannequin │ ├── Animations │ │ ├── ThirdPersonIdle.uasset │ │ ├── ThirdPersonJump_End.uasset │ │ ├── ThirdPersonJump_Loop.uasset │ │ ├── ThirdPersonJump_Start.uasset │ │ ├── ThirdPersonRun.uasset │ │ ├── ThirdPersonWalk.uasset │ │ ├── ThirdPerson_AnimBP.uasset │ │ ├── ThirdPerson_IdleRun_2D.uasset │ │ └── ThirdPerson_Jump.uasset │ └── Character │ │ ├── Materials │ │ ├── M_UE4Man_Body.uasset │ │ ├── M_UE4Man_ChestLogo.uasset │ │ └── MaterialLayers │ │ │ ├── ML_GlossyBlack_Latex_UE4.uasset │ │ │ ├── ML_Plastic_Shiny_Beige.uasset │ │ │ ├── ML_Plastic_Shiny_Beige_LOGO.uasset │ │ │ ├── ML_SoftMetal_UE4.uasset │ │ │ ├── T_ML_Aluminum01.uasset │ │ │ ├── T_ML_Aluminum01_N.uasset │ │ │ ├── T_ML_Rubber_Blue_01_D.uasset │ │ │ └── T_ML_Rubber_Blue_01_N.uasset │ │ ├── Mesh │ │ ├── SK_Mannequin.uasset │ │ ├── SK_Mannequin_PhysicsAsset.uasset │ │ └── UE4_Mannequin_Skeleton.uasset │ │ └── Textures │ │ ├── UE4Man_Logo_N.uasset │ │ ├── UE4_LOGO_CARD.uasset │ │ ├── UE4_Mannequin_MAT_MASKA.uasset │ │ └── UE4_Mannequin__normals.uasset ├── Materials │ ├── M_GroundColor.uasset │ └── M_GroundColor_Terrain.uasset ├── ThirdPerson │ └── Meshes │ │ ├── Bump_StaticMesh.uasset │ │ ├── CubeMaterial.uasset │ │ ├── LeftArm_StaticMesh.uasset │ │ ├── Linear_Stair_StaticMesh.uasset │ │ ├── RampMaterial.uasset │ │ ├── Ramp_StaticMesh.uasset │ │ └── RightArm_StaticMesh.uasset └── ThirdPersonCPP │ ├── Blueprints │ └── ThirdPersonCharacter.uasset │ └── Maps │ ├── ThirdPersonExampleMap.umap │ └── ThirdPersonExampleMap_BuiltData.uasset ├── LICENSE ├── README.md ├── SimpleFootIK.uproject └── Source ├── SimpleFootIK.Target.cs ├── SimpleFootIK ├── AnimInst_Character.cpp ├── AnimInst_Character.h ├── IK_Foot │ ├── Cpt_IK_Foot.cpp │ └── Cpt_IK_Foot.h ├── SimpleFootIK.Build.cs ├── SimpleFootIK.cpp ├── SimpleFootIK.h ├── SimpleFootIKCharacter.cpp ├── SimpleFootIKCharacter.h ├── SimpleFootIKGameMode.cpp └── SimpleFootIKGameMode.h └── SimpleFootIKEditor.Target.cs /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | [UnrealEd.SimpleMap] 2 | SimpleMapName=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap 3 | 4 | [EditoronlyBP] 5 | bAllowClassAndBlueprintPinMatching=true 6 | bReplaceBlueprintWithClass= true 7 | bDontLoadBlueprintOutsideEditor= true 8 | bBlueprintIsNotBlueprintType= true 9 | 10 | 11 | -------------------------------------------------------------------------------- /Config/DefaultEditorPerProjectUserSettings.ini: -------------------------------------------------------------------------------- 1 | [ContentBrowser] 2 | ContentBrowserTab1.SelectedPaths=/Game/ThirdPersonCPP -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GameMapsSettings] 2 | GameDefaultMap=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap 3 | EditorStartupMap=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap 4 | GlobalDefaultGameMode="/Script/SimpleFootIK.SimpleFootIKGameMode" 5 | 6 | [/Script/IOSRuntimeSettings.IOSRuntimeSettings] 7 | MinimumiOSVersion=IOS_10 8 | bSupportsPortraitOrientation=False 9 | bSupportsUpsideDownOrientation=False 10 | bSupportsLandscapeLeftOrientation=True 11 | PreferredLandscapeOrientation=LandscapeLeft 12 | 13 | [/Script/Engine.Engine] 14 | +ActiveGameNameRedirects=(OldGameName="TP_ThirdPerson",NewGameName="/Script/SimpleFootIK") 15 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_ThirdPerson",NewGameName="/Script/SimpleFootIK") 16 | +ActiveClassRedirects=(OldClassName="TP_ThirdPersonGameMode",NewClassName="SimpleFootIKGameMode") 17 | +ActiveClassRedirects=(OldClassName="TP_ThirdPersonCharacter",NewClassName="SimpleFootIKCharacter") 18 | 19 | [/Script/HardwareTargeting.HardwareTargetingSettings] 20 | TargetedHardwareClass=Desktop 21 | AppliedTargetedHardwareClass=Desktop 22 | DefaultGraphicsPerformance=Maximum 23 | AppliedDefaultGraphicsPerformance=Maximum 24 | 25 | [/Script/Engine.PhysicsSettings] 26 | DefaultGravityZ=-980.000000 27 | DefaultTerminalVelocity=4000.000000 28 | DefaultFluidFriction=0.300000 29 | SimulateScratchMemorySize=262144 30 | RagdollAggregateThreshold=4 31 | TriangleMeshTriangleMinAreaThreshold=5.000000 32 | bEnableAsyncScene=False 33 | bEnableShapeSharing=False 34 | bEnablePCM=True 35 | bEnableStabilization=False 36 | bWarnMissingLocks=True 37 | bEnable2DPhysics=False 38 | PhysicErrorCorrection=(PingExtrapolation=0.100000,PingLimit=100.000000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,MaxLinearHardSnapDistance=400.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000) 39 | LockedAxis=Invalid 40 | DefaultDegreesOfFreedom=Full3D 41 | BounceThresholdVelocity=200.000000 42 | FrictionCombineMode=Average 43 | RestitutionCombineMode=Average 44 | MaxAngularVelocity=3600.000000 45 | MaxDepenetrationVelocity=0.000000 46 | ContactOffsetMultiplier=0.020000 47 | MinContactOffset=2.000000 48 | MaxContactOffset=8.000000 49 | bSimulateSkeletalMeshOnDedicatedServer=True 50 | DefaultShapeComplexity=CTF_UseSimpleAndComplex 51 | bDefaultHasComplexCollision=True 52 | bSuppressFaceRemapTable=False 53 | bSupportUVFromHitResults=False 54 | bDisableActiveActors=False 55 | bDisableKinematicStaticPairs=False 56 | bDisableKinematicKinematicPairs=False 57 | bDisableCCD=False 58 | bEnableEnhancedDeterminism=False 59 | MaxPhysicsDeltaTime=0.033333 60 | bSubstepping=False 61 | bSubsteppingAsync=False 62 | MaxSubstepDeltaTime=0.016667 63 | MaxSubsteps=6 64 | SyncSceneSmoothingFactor=0.000000 65 | AsyncSceneSmoothingFactor=0.990000 66 | InitialAverageFrameRate=0.016667 67 | PhysXTreeRebuildRate=10 68 | DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2) 69 | -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GeneralProjectSettings] 2 | ProjectID=2F2018154DCBF9FDFFD7EBB051C40775 3 | ProjectName=SimpleFootIK 4 | Description=CatDark's SimpleFootIK 5 | CompanyName=CatDark 6 | CompanyDistinguishedName=CatDark 7 | LicensingTerms=The MIT License (MIT) 8 | CopyrightNotice=Copyright (c) 2019 CatDark, All Rights Reserved. 9 | ProjectDisplayedTitle=NSLOCTEXT("[/Script/EngineSettings]", "518D298A41683B5923873EA0480D12A8", "SimpleFootIK") 10 | ProjectDebugTitleInfo=NSLOCTEXT("[/Script/EngineSettings]", "2AF5FD39429DA602A47E4683211346DE", "SimpleFootIK_Debug") 11 | ProjectVersion=0.0.0.1 12 | 13 | -------------------------------------------------------------------------------- /Config/DefaultInput.ini: -------------------------------------------------------------------------------- 1 | 2 | [/Script/Engine.InputSettings] 3 | -AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 4 | -AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 5 | -AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 6 | -AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 7 | -AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 8 | -AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 9 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 10 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 11 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 12 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 13 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 14 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 15 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Z",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 16 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Z",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 17 | +AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 18 | +AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 19 | +AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 20 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 21 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 22 | +AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 23 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 24 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 25 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 26 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 27 | +AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 28 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 29 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 30 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 31 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 32 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 33 | +AxisConfig=(AxisKeyName="OculusTouch_Left_FaceButton1",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 34 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 35 | +AxisConfig=(AxisKeyName="OculusTouch_Left_FaceButton2",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 36 | +AxisConfig=(AxisKeyName="OculusTouch_Left_IndexPointing",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 37 | +AxisConfig=(AxisKeyName="OculusTouch_Left_ThumbUp",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 38 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 39 | +AxisConfig=(AxisKeyName="OculusTouch_Right_FaceButton1",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 40 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 41 | +AxisConfig=(AxisKeyName="OculusTouch_Right_FaceButton2",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 42 | +AxisConfig=(AxisKeyName="OculusTouch_Right_IndexPointing",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 43 | +AxisConfig=(AxisKeyName="OculusTouch_Right_ThumbUp",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 44 | +AxisConfig=(AxisKeyName="OculusTouchpad_Touchpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 45 | +AxisConfig=(AxisKeyName="OculusTouchpad_Touchpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 46 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_HandGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 47 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_IndexGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 48 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_MiddleGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 49 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_RingGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 50 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_PinkyGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 51 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_HandGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 52 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_IndexGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 53 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_MiddleGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 54 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_RingGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 55 | +AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_PinkyGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 56 | bAltEnterTogglesFullscreen=True 57 | bF11TogglesFullscreen=True 58 | bUseMouseForTouch=False 59 | bEnableMouseSmoothing=True 60 | bEnableFOVScaling=True 61 | bCaptureMouseOnLaunch=True 62 | bDefaultViewportMouseLock=False 63 | bAlwaysShowTouchInterface=False 64 | bShowConsoleOnFourFingerTap=True 65 | bEnableGestureRecognizer=False 66 | bUseAutocorrect=False 67 | DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown 68 | DefaultViewportMouseLockMode=LockOnCapture 69 | FOVScale=0.011110 70 | DoubleClickTime=0.200000 71 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) 72 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom) 73 | +ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R) 74 | +ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Left_Grip1) 75 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouchpad_Touchpad) 76 | +ActionMappings=(ActionName="Sprint",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftShift) 77 | +ActionMappings=(ActionName="Debug",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R) 78 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) 79 | +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S) 80 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Up) 81 | +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=Down) 82 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Gamepad_LeftY) 83 | +AxisMappings=(AxisName="MoveRight",Scale=-1.000000,Key=A) 84 | +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D) 85 | +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=Gamepad_LeftX) 86 | +AxisMappings=(AxisName="TurnRate",Scale=1.000000,Key=Gamepad_RightX) 87 | +AxisMappings=(AxisName="TurnRate",Scale=-1.000000,Key=Left) 88 | +AxisMappings=(AxisName="TurnRate",Scale=1.000000,Key=Right) 89 | +AxisMappings=(AxisName="Turn",Scale=1.000000,Key=MouseX) 90 | +AxisMappings=(AxisName="LookUpRate",Scale=1.000000,Key=Gamepad_RightY) 91 | +AxisMappings=(AxisName="LookUp",Scale=-1.000000,Key=MouseY) 92 | DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks 93 | ConsoleKey=None 94 | -ConsoleKeys=Tilde 95 | +ConsoleKeys=Tilde 96 | 97 | 98 | -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Geometry/Meshes/1M_Cube.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube_Chamfer.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Geometry/Meshes/1M_Cube_Chamfer.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Geometry/Meshes/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/TemplateFloor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Geometry/Meshes/TemplateFloor.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonIdle.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonIdle.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_End.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonJump_End.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonJump_Loop.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_Start.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonJump_Start.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonRun.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonRun.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonWalk.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPersonWalk.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_AnimBP.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPerson_AnimBP.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_IdleRun_2D.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPerson_IdleRun_2D.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_Jump.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Animations/ThirdPerson_Jump.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/M_UE4Man_Body.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/M_UE4Man_Body.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/M_UE4Man_ChestLogo.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/M_UE4Man_ChestLogo.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/SK_Mannequin.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Mesh/SK_Mannequin.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/SK_Mannequin_PhysicsAsset.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Mesh/SK_Mannequin_PhysicsAsset.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/UE4_Mannequin_Skeleton.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Mesh/UE4_Mannequin_Skeleton.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4Man_Logo_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Textures/UE4Man_Logo_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_LOGO_CARD.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Textures/UE4_LOGO_CARD.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_Mannequin_MAT_MASKA.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Textures/UE4_Mannequin_MAT_MASKA.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_Mannequin__normals.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Mannequin/Character/Textures/UE4_Mannequin__normals.uasset -------------------------------------------------------------------------------- /Content/Materials/M_GroundColor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Materials/M_GroundColor.uasset -------------------------------------------------------------------------------- /Content/Materials/M_GroundColor_Terrain.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/Materials/M_GroundColor_Terrain.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Bump_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/Bump_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/LeftArm_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/LeftArm_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Linear_Stair_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/Linear_Stair_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/RampMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/RampMaterial.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Ramp_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/Ramp_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/RightArm_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPerson/Meshes/RightArm_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPersonCPP/Blueprints/ThirdPersonCharacter.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonCPP/Maps/ThirdPersonExampleMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPersonCPP/Maps/ThirdPersonExampleMap.umap -------------------------------------------------------------------------------- /Content/ThirdPersonCPP/Maps/ThirdPersonExampleMap_BuiltData.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatDarkGame/UE4SimpleFootIKcpp/b80a9ef52cec25ba2179dc02664eb5240e74a626/Content/ThirdPersonCPP/Maps/ThirdPersonExampleMap_BuiltData.uasset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2019 CatDark, All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UE4SimpleFootIKcpp 2 | UE4 Simple FootIK with C++ Project. 3 | 4 | - Support Unreal Engine 4 Version : 4.21.2 5 | 6 | --------------------- 7 | 8 | ## About 9 | 10 | I'm CatDark. 11 | 12 | This project is simple foot ik with full C++ on UE4. 13 | 14 | Thank you! 15 | 16 | --------------------- 17 | 18 | # License 19 | 20 | 21 | 22 | The MIT License (MIT) 23 | 24 | Copyright (c) 2019 CatDark, All Rights Reserved. 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 32 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 33 | OTHER DEALINGS IN THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /SimpleFootIK.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.21", 4 | "Category": "", 5 | "Description": "Copyright(c) 2019 CatDark, All Rights Reserved.", 6 | "Modules": [ 7 | { 8 | "Name": "SimpleFootIK", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default", 11 | "AdditionalDependencies": [ 12 | "Engine", 13 | "CoreUObject" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /Source/SimpleFootIK.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class SimpleFootIKTarget : TargetRules 7 | { 8 | public SimpleFootIKTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | ExtraModuleNames.Add("SimpleFootIK"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/AnimInst_Character.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #include "AnimInst_Character.h" 4 | 5 | UAnimInst_Character::UAnimInst_Character() 6 | { 7 | 8 | } 9 | 10 | void UAnimInst_Character::NativeInitializeAnimation() 11 | { 12 | Super::NativeInitializeAnimation(); 13 | Init_IKFootRef(); 14 | 15 | } 16 | 17 | void UAnimInst_Character::NativeUpdateAnimation(float DeltaSeconds) 18 | { 19 | Super::NativeUpdateAnimation(DeltaSeconds); 20 | Tick_IKFoot(); 21 | 22 | } 23 | 24 | void UAnimInst_Character::Init_IKFootRef() 25 | { 26 | //! Get IKFoot Component from owner 27 | APawn* pOwner = TryGetPawnOwner(); 28 | if (pOwner != nullptr) 29 | { 30 | UActorComponent* pActorComp = pOwner->GetComponentByClass(UCpt_IK_Foot::StaticClass()); 31 | if (pActorComp != nullptr) 32 | { 33 | m_pIK_Foot_Ref = Cast(pActorComp); 34 | if (m_pIK_Foot_Ref == nullptr) 35 | { 36 | UE_LOG(LogTemp, Warning, TEXT("IKFootRef is nullptr")); 37 | } 38 | } 39 | } 40 | } 41 | 42 | void UAnimInst_Character::Tick_IKFoot() 43 | { 44 | if (m_pIK_Foot_Ref == nullptr) return; 45 | 46 | m_stIKAnimValue = m_pIK_Foot_Ref->GetIKAnimValue(); 47 | } 48 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/AnimInst_Character.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #pragma once 4 | #include "IK_Foot/Cpt_IK_Foot.h" 5 | 6 | #include "CoreMinimal.h" 7 | #include "Animation/AnimInstance.h" 8 | #include "AnimInst_Character.generated.h" 9 | 10 | 11 | 12 | UCLASS() 13 | class SIMPLEFOOTIK_API UAnimInst_Character : public UAnimInstance 14 | { 15 | GENERATED_BODY() 16 | public: 17 | UAnimInst_Character(); 18 | virtual void NativeInitializeAnimation() override; 19 | virtual void NativeUpdateAnimation(float DeltaSeconds) override; 20 | 21 | private : 22 | //! IK Component Init 23 | void Init_IKFootRef(); 24 | 25 | //! IK Component Tick 26 | void Tick_IKFoot(); 27 | 28 | //! IK Component Ref 29 | UPROPERTY() 30 | class UCpt_IK_Foot* m_pIK_Foot_Ref; 31 | 32 | //! IK Component Animvalue struct 33 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "IKFoot Value", meta = (AllowPrivateAccess = "true")) 34 | FST_IK_AnimValue m_stIKAnimValue; 35 | }; 36 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/IK_Foot/Cpt_IK_Foot.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #include "Cpt_IK_Foot.h" 4 | #include "GameFramework/Character.h" 5 | #include "Animation/AnimInstance.h" 6 | #include "Kismet/KismetMathLibrary.h" 7 | #include "Kismet/KismetSystemLibrary.h" 8 | #include "Components/CapsuleComponent.h" 9 | 10 | 11 | UCpt_IK_Foot::UCpt_IK_Foot() 12 | { 13 | PrimaryComponentTick.bCanEverTick = true; 14 | 15 | m_fIKFeetInterpSpeed = 22.0f; 16 | m_fIKHipsInterpSpeed = 17.0f; 17 | m_fIKTraceDistance = 55.0f; 18 | m_IKAdjustOffset = 5.0f; 19 | 20 | m_bDebug = false; 21 | } 22 | 23 | // Called when the game starts 24 | void UCpt_IK_Foot::BeginPlay() 25 | { 26 | Super::BeginPlay(); 27 | 28 | m_fDeltaTime = 0.0f; 29 | 30 | m_pCharacter = Cast(GetOwner()); 31 | if (m_pCharacter == nullptr) return; 32 | 33 | m_fIKCapsuleHalkHeight = m_pCharacter->GetCapsuleComponent()->GetScaledCapsuleHalfHeight(); 34 | 35 | SetIKActive(true); 36 | } 37 | 38 | void UCpt_IK_Foot::EndPlay(const EEndPlayReason::Type EndPlayReason) 39 | { 40 | Super::EndPlay(EndPlayReason); 41 | m_pCharacter = nullptr; 42 | } 43 | 44 | // Called every frame 45 | void UCpt_IK_Foot::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 46 | { 47 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 48 | if (m_pCharacter == nullptr) return; 49 | if (m_bActive == false) return; 50 | 51 | IK_Update(DeltaTime); 52 | IK_Debug(); 53 | } 54 | 55 | void UCpt_IK_Foot::Set_IKSocketName(FString sSocName_LeftFoot, FString sSocName_RightFoot) 56 | { 57 | m_sIKSocketName_LeftFoot = FName(*sSocName_LeftFoot); 58 | m_sIKSocketName_RightFoot = FName(*sSocName_RightFoot); 59 | } 60 | 61 | void UCpt_IK_Foot::IK_ResetVars() 62 | { 63 | //! All reset the Animvalues 64 | IK_Update_FootOffset(m_fDeltaTime, 0.0f, &m_stIKAnimValuse.m_fEffectorLocation_Right, m_fIKFeetInterpSpeed); 65 | IK_Update_FootOffset(m_fDeltaTime, 0.0f, &m_stIKAnimValuse.m_fEffectorLocation_Left, m_fIKFeetInterpSpeed); 66 | 67 | IK_Update_FootRotation(m_fDeltaTime, FRotator::ZeroRotator, &m_stIKAnimValuse.m_pFootRotation_Right, m_fIKFeetInterpSpeed); 68 | IK_Update_FootRotation(m_fDeltaTime, FRotator::ZeroRotator, &m_stIKAnimValuse.m_pFootRotation_Left, m_fIKFeetInterpSpeed); 69 | 70 | IK_Update_FootOffset(m_fDeltaTime, 0.0f, &m_stIKAnimValuse.m_fHipOffset, m_fIKHipsInterpSpeed); 71 | IK_Update_CapsuleHalfHeight(m_fDeltaTime, 0.0f, true); 72 | } 73 | 74 | void UCpt_IK_Foot::IK_Update(float fDeltaTime) 75 | { 76 | m_fDeltaTime = fDeltaTime; 77 | 78 | //! Get Line Trace Info of ground from foot 79 | ST_IK_TraceInfo pTrace_Left = IK_FootTrace(m_fIKTraceDistance, m_sIKSocketName_LeftFoot); 80 | ST_IK_TraceInfo pTrace_Right = IK_FootTrace(m_fIKTraceDistance, m_sIKSocketName_RightFoot); 81 | 82 | if (IsMoving() == false) 83 | { 84 | //! Update foot rotation from Impact normal 85 | IK_Update_FootRotation(fDeltaTime, NormalToRotator(pTrace_Left.pImpactLocation), &m_stIKAnimValuse.m_pFootRotation_Left, m_fIKFeetInterpSpeed); 86 | IK_Update_FootRotation(fDeltaTime, NormalToRotator(pTrace_Right.pImpactLocation), &m_stIKAnimValuse.m_pFootRotation_Right, m_fIKFeetInterpSpeed); 87 | } 88 | else 89 | { 90 | IK_Update_FootRotation(fDeltaTime, FRotator::ZeroRotator, &m_stIKAnimValuse.m_pFootRotation_Right, m_fIKFeetInterpSpeed); 91 | IK_Update_FootRotation(fDeltaTime, FRotator::ZeroRotator, &m_stIKAnimValuse.m_pFootRotation_Left, m_fIKFeetInterpSpeed); 92 | } 93 | 94 | 95 | //! Update Hip Offset(Z) 96 | //! Get Hip(Pelvis)Offset from foot offset and set CapsuleComponent height 97 | float fHipsOffset = UKismetMathLibrary::Min(pTrace_Left.fOffset, pTrace_Right.fOffset); 98 | if (fHipsOffset < 0.0f == false) fHipsOffset = 0.0f; 99 | IK_Update_FootOffset(fDeltaTime, fHipsOffset, &m_stIKAnimValuse.m_fHipOffset, m_fIKHipsInterpSpeed); 100 | IK_Update_CapsuleHalfHeight(fDeltaTime, fHipsOffset, false); 101 | 102 | //! Update effector locations of foot 103 | IK_Update_FootOffset(fDeltaTime, pTrace_Left.fOffset - fHipsOffset, &m_stIKAnimValuse.m_fEffectorLocation_Left, m_fIKFeetInterpSpeed); 104 | IK_Update_FootOffset(fDeltaTime, -1*(pTrace_Right.fOffset - fHipsOffset), &m_stIKAnimValuse.m_fEffectorLocation_Right, m_fIKFeetInterpSpeed); 105 | 106 | //! When foot is close to trace effector location disable IK 107 | //bool bLeftFootNearly = UKismetMathLibrary::NearlyEqual_FloatFloat(m_stIKAnimValuse.m_fEffectorLocation_Left, pTrace_Left.fOffset - fHipsOffset, 1.0f); 108 | //bool bRightFootNearly = UKismetMathLibrary::NearlyEqual_FloatFloat(m_stIKAnimValuse.m_fEffectorLocation_Right, pTrace_Right.fOffset - fHipsOffset, 1.0f); 109 | //if (bLeftFootNearly == true && bRightFootNearly == true) SetIKActive(false); 110 | 111 | } 112 | 113 | void UCpt_IK_Foot::IK_Debug() 114 | { 115 | //! Debug AnimValues at Printstring 116 | if (m_bDebug == true) 117 | { 118 | UKismetSystemLibrary::PrintString(GetWorld(), "Foot_L Rotation : " + m_stIKAnimValuse.m_pFootRotation_Left.ToString(), true, false, FLinearColor::Red, 0.0f); 119 | UKismetSystemLibrary::PrintString(GetWorld(), "Foot_R Rotation : " + m_stIKAnimValuse.m_pFootRotation_Right.ToString(), true, false, FLinearColor::Red, 0.0f); 120 | UKismetSystemLibrary::PrintString(GetWorld(), "Foot_L EffectorLocation(Z) : " + FString::SanitizeFloat(m_stIKAnimValuse.m_fEffectorLocation_Left), true, false, FLinearColor::Red, 0.0f); 121 | UKismetSystemLibrary::PrintString(GetWorld(), "Foot_R EffectorLocation(Z) : " + FString::SanitizeFloat(m_stIKAnimValuse.m_fEffectorLocation_Right), true, false, FLinearColor::Red, 0.0f); 122 | UKismetSystemLibrary::PrintString(GetWorld(), "HipOffset(Z) : " + FString::SanitizeFloat(m_stIKAnimValuse.m_fHipOffset), true, false, FLinearColor::Red, 0.0f); 123 | } 124 | 125 | //! Debug the show Characters capsule collider 126 | if (m_pCharacter != nullptr) 127 | { 128 | if (m_pCharacter->GetCapsuleComponent()->bHiddenInGame == m_bDebug) 129 | { 130 | m_pCharacter->GetCapsuleComponent()->bHiddenInGame = !m_bDebug; 131 | } 132 | } 133 | } 134 | 135 | void UCpt_IK_Foot::SetIKDebug(bool bActive) 136 | { 137 | m_bDebug = bActive; 138 | } 139 | 140 | 141 | void UCpt_IK_Foot::IK_Update_FootOffset(float fDeltaTime, float fTargetValue, float* fEffectorValue, float fInterpSpeed) 142 | { 143 | //! Set foot Effectlocation value with FInterpTo 144 | float fInterpValue = UKismetMathLibrary::FInterpTo(*fEffectorValue, fTargetValue, fDeltaTime, fInterpSpeed); 145 | *fEffectorValue = fInterpValue; 146 | } 147 | 148 | void UCpt_IK_Foot::IK_Update_FootRotation(float fDeltaTime, FRotator pTargetValue, FRotator * pFootRotatorValue, float fInterpSpeed) 149 | { 150 | //! Set Foot Rotation value with FInterpTo 151 | FRotator pInterpRotator = UKismetMathLibrary::RInterpTo(*pFootRotatorValue, pTargetValue, fDeltaTime, fInterpSpeed); 152 | *pFootRotatorValue = pInterpRotator; 153 | } 154 | 155 | void UCpt_IK_Foot::IK_Update_CapsuleHalfHeight(float fDeltaTime, float fHipsShifts, bool bResetDefault) 156 | { 157 | UCapsuleComponent* pCapsule = m_pCharacter->GetCapsuleComponent(); 158 | if (pCapsule == nullptr) 159 | { 160 | UE_LOG(LogTemp, Warning, TEXT("IK : Capsule is NULL")); 161 | return; 162 | } 163 | 164 | //! Get Half Height of capsule component 165 | float fCapsuleHalf = 0.0f; 166 | if (bResetDefault == true) 167 | { 168 | fCapsuleHalf = m_fIKCapsuleHalkHeight; 169 | } 170 | else 171 | { 172 | float fHalfAbsSize = UKismetMathLibrary::Abs(fHipsShifts) * 0.5f; 173 | fCapsuleHalf = m_fIKCapsuleHalkHeight - fHalfAbsSize; 174 | } 175 | 176 | //! Set capsule component height with FInterpTo 177 | float fScaledCapsuleHalfHeight = pCapsule->GetScaledCapsuleHalfHeight(); 178 | float fInterpValue = UKismetMathLibrary::FInterpTo(fScaledCapsuleHalfHeight, fCapsuleHalf, fDeltaTime, m_fIKHipsInterpSpeed); 179 | 180 | pCapsule->SetCapsuleHalfHeight(fInterpValue, true); 181 | } 182 | 183 | ST_IK_TraceInfo UCpt_IK_Foot::IK_FootTrace(float fTraceDistance, FName sSocket) 184 | { 185 | ST_IK_TraceInfo pTraceInfo; 186 | 187 | //! Set Linetraces startpoint and end point 188 | FVector pSocketLocation = m_pCharacter->GetMesh()->GetSocketLocation(sSocket); 189 | FVector pLine_Start = FVector(pSocketLocation.X, pSocketLocation.Y, m_pCharacter->GetActorLocation().Z); 190 | FVector pLine_End = FVector(pSocketLocation.X, pSocketLocation.Y 191 | , (m_pCharacter->GetActorLocation().Z - m_fIKCapsuleHalkHeight) - fTraceDistance); 192 | 193 | //! Process Line Trace 194 | FHitResult pHitResult; 195 | TArray pIgnore; 196 | pIgnore.Add(GetOwner()); 197 | 198 | EDrawDebugTrace::Type eDebug = EDrawDebugTrace::None; 199 | if (m_bDebug == true) eDebug = EDrawDebugTrace::ForOneFrame; 200 | 201 | bool bResult = UKismetSystemLibrary::LineTraceSingle(GetWorld(), pLine_Start, pLine_End, 202 | UEngineTypes::ConvertToTraceType(ECC_Visibility), true, pIgnore, eDebug, pHitResult, true); 203 | 204 | //! Set ImpactNormal and Offset from HitResult 205 | pTraceInfo.pImpactLocation = pHitResult.ImpactNormal; 206 | if (pHitResult.IsValidBlockingHit() == true) 207 | { 208 | float fImpactLegth = (pHitResult.ImpactPoint - pHitResult.TraceEnd).Size(); 209 | pTraceInfo.fOffset = m_IKAdjustOffset + (fImpactLegth - fTraceDistance); 210 | } 211 | else 212 | { 213 | pTraceInfo.fOffset = 0.0f; 214 | } 215 | 216 | return pTraceInfo; 217 | } 218 | 219 | bool UCpt_IK_Foot::IsMoving() 220 | { 221 | float fSpeed = m_pCharacter->GetVelocity().Size(); 222 | if (fSpeed > 0.0f) return true; 223 | return false; 224 | } 225 | 226 | void UCpt_IK_Foot::SetIKActive(bool bActive) 227 | { 228 | m_bActive = bActive; 229 | } 230 | 231 | FRotator UCpt_IK_Foot::NormalToRotator(FVector pVector) 232 | { 233 | float fAtan2_1 = UKismetMathLibrary::DegAtan2(pVector.Y, pVector.Z); 234 | float fAtan2_2 = UKismetMathLibrary::DegAtan2(pVector.X, pVector.Z); 235 | fAtan2_2 *= -1.0f; 236 | FRotator pResult = FRotator(fAtan2_2, 0.0f, fAtan2_1); 237 | 238 | return pResult; 239 | } -------------------------------------------------------------------------------- /Source/SimpleFootIK/IK_Foot/Cpt_IK_Foot.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Components/ActorComponent.h" 7 | #include "Cpt_IK_Foot.generated.h" 8 | 9 | //! Line Trace info struct 10 | typedef struct ST_IK_TraceInfo 11 | { 12 | float fOffset; 13 | FVector pImpactLocation; 14 | }; 15 | 16 | //! IK Anim Instance Value struct 17 | USTRUCT(Atomic, BlueprintType) 18 | struct FST_IK_AnimValue 19 | { 20 | GENERATED_BODY() 21 | 22 | public : 23 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 24 | float m_fEffectorLocation_Left; 25 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 26 | float m_fEffectorLocation_Right; 27 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 28 | FRotator m_pFootRotation_Left; 29 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 30 | FRotator m_pFootRotation_Right; 31 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 32 | float m_fHipOffset; 33 | }; 34 | 35 | UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) 36 | class SIMPLEFOOTIK_API UCpt_IK_Foot : public UActorComponent 37 | { 38 | GENERATED_BODY() 39 | 40 | private : 41 | UPROPERTY() 42 | class ACharacter* m_pCharacter; 43 | 44 | private: 45 | //! Owner Characters capsule height 46 | float m_fIKCapsuleHalkHeight; 47 | 48 | //! IK Anim Instance Value struct 49 | FST_IK_AnimValue m_stIKAnimValuse; 50 | 51 | //! IK Active state 52 | bool m_bActive = false; 53 | 54 | float m_fDeltaTime = 0.0f; 55 | public: 56 | //! Default Values 57 | 58 | //! Left foot bone name 59 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values Socket") 60 | FName m_sIKSocketName_LeftFoot; 61 | //! Right foot bone name 62 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values Socket") 63 | FName m_sIKSocketName_RightFoot; 64 | 65 | //! Distance between the floor and the foot 66 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values") 67 | float m_IKAdjustOffset; 68 | 69 | //! Max Linetrace distance 70 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values") 71 | float m_fIKTraceDistance; 72 | 73 | //! Hip(pelvis) move speed 74 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values") 75 | float m_fIKHipsInterpSpeed; 76 | 77 | //! Leg joing move speed 78 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Values") 79 | float m_fIKFeetInterpSpeed; 80 | 81 | //! Enable debug mode 82 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IK Debug") 83 | bool m_bDebug; 84 | 85 | public: 86 | UCpt_IK_Foot(); 87 | virtual void BeginPlay() override; 88 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 89 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 90 | 91 | //! Set foot bone name from skeletalmesh 92 | void Set_IKSocketName(FString sSocName_LeftFoot, FString sSocName_RightFoot); 93 | 94 | //! Reset IK State 95 | void IK_ResetVars(); 96 | 97 | //! Set IK Active state 98 | void SetIKActive(bool bActive); 99 | 100 | //! Set IK Debug state 101 | void SetIKDebug(bool bActive); 102 | 103 | private : 104 | //! IK process update 105 | void IK_Update(float fDeltaTime); 106 | 107 | //! IK Debug mode update 108 | void IK_Debug(); 109 | 110 | //! process IK Foot,leg Z Offset 111 | void IK_Update_FootOffset(float fDeltaTime, float fTargetValue, float* fEffectorValue, float fInterpSpeed); 112 | 113 | //! Process IK Foot rotation from ground normal 114 | void IK_Update_FootRotation(float fDeltaTime, FRotator pTargetValue, FRotator* pFootRotatorValue, float fInterpSpeed); 115 | 116 | //! Process IK characters capsule component Z Offset 117 | void IK_Update_CapsuleHalfHeight(float fDeltaTime, float fHipsShifts, bool bResetDefault); 118 | 119 | //! Get foot line trace info 120 | ST_IK_TraceInfo IK_FootTrace(float fTraceDistance, FName sSocket); 121 | 122 | //! Get ground normal 123 | FRotator NormalToRotator(FVector pVector); 124 | 125 | //! Check owner character is moving 126 | bool IsMoving(); 127 | 128 | public : 129 | FORCEINLINE FST_IK_AnimValue GetIKAnimValue() { return m_stIKAnimValuse; } 130 | FORCEINLINE bool GetIKDebugState() { return m_bDebug; } 131 | }; 132 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIK.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class SimpleFootIK : ModuleRules 6 | { 7 | public SimpleFootIK(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" }); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIK.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #include "SimpleFootIK.h" 4 | #include "Modules/ModuleManager.h" 5 | 6 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, SimpleFootIK, "SimpleFootIK" ); 7 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIK.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIKCharacter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #include "SimpleFootIKCharacter.h" 4 | #include "HeadMountedDisplayFunctionLibrary.h" 5 | #include "Camera/CameraComponent.h" 6 | #include "Components/CapsuleComponent.h" 7 | #include "Components/InputComponent.h" 8 | #include "GameFramework/CharacterMovementComponent.h" 9 | #include "GameFramework/Controller.h" 10 | #include "GameFramework/SpringArmComponent.h" 11 | 12 | #include "IK_Foot/Cpt_IK_Foot.h" 13 | 14 | ////////////////////////////////////////////////////////////////////////// 15 | // ASimpleFootIKCharacter 16 | 17 | ASimpleFootIKCharacter::ASimpleFootIKCharacter() 18 | { 19 | // Set size for collision capsule 20 | GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f); 21 | 22 | // set our turn rates for input 23 | BaseTurnRate = 45.f; 24 | BaseLookUpRate = 45.f; 25 | 26 | // Don't rotate when the controller rotates. Let that just affect the camera. 27 | bUseControllerRotationPitch = false; 28 | bUseControllerRotationYaw = false; 29 | bUseControllerRotationRoll = false; 30 | 31 | // Configure character movement 32 | GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input... 33 | GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate 34 | GetCharacterMovement()->JumpZVelocity = 600.f; 35 | GetCharacterMovement()->AirControl = 0.2f; 36 | GetCharacterMovement()->MaxWalkSpeed = 200.0f; 37 | 38 | // Create a camera boom (pulls in towards the player if there is a collision) 39 | CameraBoom = CreateDefaultSubobject(TEXT("CameraBoom")); 40 | CameraBoom->SetupAttachment(RootComponent); 41 | CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character 42 | CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller 43 | 44 | // Create a follow camera 45 | FollowCamera = CreateDefaultSubobject(TEXT("FollowCamera")); 46 | FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation 47 | FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm 48 | 49 | // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) 50 | // are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++) 51 | 52 | //! Init IK Foot Component 53 | m_pIK_Foot = CreateDefaultSubobject(TEXT("IK_Foot")); 54 | //! Set Foot bone name to IK Component 55 | m_pIK_Foot->Set_IKSocketName(TEXT("foot_l"), TEXT("foot_r")); 56 | } 57 | 58 | ////////////////////////////////////////////////////////////////////////// 59 | // Input 60 | 61 | void ASimpleFootIKCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) 62 | { 63 | // Set up gameplay key bindings 64 | check(PlayerInputComponent); 65 | PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump); 66 | PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping); 67 | 68 | PlayerInputComponent->BindAxis("MoveForward", this, &ASimpleFootIKCharacter::MoveForward); 69 | PlayerInputComponent->BindAxis("MoveRight", this, &ASimpleFootIKCharacter::MoveRight); 70 | 71 | // We have 2 versions of the rotation bindings to handle different kinds of devices differently 72 | // "turn" handles devices that provide an absolute delta, such as a mouse. 73 | // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick 74 | PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput); 75 | PlayerInputComponent->BindAxis("TurnRate", this, &ASimpleFootIKCharacter::TurnAtRate); 76 | PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput); 77 | PlayerInputComponent->BindAxis("LookUpRate", this, &ASimpleFootIKCharacter::LookUpAtRate); 78 | 79 | // handle touch devices 80 | PlayerInputComponent->BindTouch(IE_Pressed, this, &ASimpleFootIKCharacter::TouchStarted); 81 | PlayerInputComponent->BindTouch(IE_Released, this, &ASimpleFootIKCharacter::TouchStopped); 82 | 83 | // VR headset functionality 84 | PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &ASimpleFootIKCharacter::OnResetVR); 85 | 86 | PlayerInputComponent->BindAction("Sprint", IE_Pressed, this, &ASimpleFootIKCharacter::Sprint_Press); 87 | PlayerInputComponent->BindAction("Sprint", IE_Released, this, &ASimpleFootIKCharacter::Sprint_Release); 88 | 89 | PlayerInputComponent->BindAction("Debug", IE_Pressed, this, &ASimpleFootIKCharacter::IKDebugToggle); 90 | } 91 | 92 | void ASimpleFootIKCharacter::IKDebugToggle() 93 | { 94 | m_pIK_Foot->SetIKDebug(!m_pIK_Foot->GetIKDebugState()); 95 | } 96 | 97 | void ASimpleFootIKCharacter::Sprint_Press() 98 | { 99 | GetCharacterMovement()->MaxWalkSpeed = 600.0f; 100 | } 101 | 102 | void ASimpleFootIKCharacter::Sprint_Release() 103 | { 104 | GetCharacterMovement()->MaxWalkSpeed = 200.0f; 105 | } 106 | 107 | void ASimpleFootIKCharacter::OnResetVR() 108 | { 109 | UHeadMountedDisplayFunctionLibrary::ResetOrientationAndPosition(); 110 | } 111 | 112 | void ASimpleFootIKCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location) 113 | { 114 | Jump(); 115 | } 116 | 117 | void ASimpleFootIKCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location) 118 | { 119 | StopJumping(); 120 | } 121 | 122 | void ASimpleFootIKCharacter::TurnAtRate(float Rate) 123 | { 124 | // calculate delta for this frame from the rate information 125 | AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds()); 126 | } 127 | 128 | void ASimpleFootIKCharacter::LookUpAtRate(float Rate) 129 | { 130 | // calculate delta for this frame from the rate information 131 | AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds()); 132 | } 133 | 134 | void ASimpleFootIKCharacter::MoveForward(float Value) 135 | { 136 | if ((Controller != NULL) && (Value != 0.0f)) 137 | { 138 | // find out which way is forward 139 | const FRotator Rotation = Controller->GetControlRotation(); 140 | const FRotator YawRotation(0, Rotation.Yaw, 0); 141 | 142 | // get forward vector 143 | const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); 144 | AddMovementInput(Direction, Value); 145 | } 146 | } 147 | 148 | void ASimpleFootIKCharacter::MoveRight(float Value) 149 | { 150 | if ( (Controller != NULL) && (Value != 0.0f) ) 151 | { 152 | // find out which way is right 153 | const FRotator Rotation = Controller->GetControlRotation(); 154 | const FRotator YawRotation(0, Rotation.Yaw, 0); 155 | 156 | // get right vector 157 | const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y); 158 | // add movement in that direction 159 | AddMovementInput(Direction, Value); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIKCharacter.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/Character.h" 7 | #include "SimpleFootIKCharacter.generated.h" 8 | 9 | UCLASS(config=Game) 10 | class ASimpleFootIKCharacter : public ACharacter 11 | { 12 | GENERATED_BODY() 13 | 14 | /** Camera boom positioning the camera behind the character */ 15 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) 16 | class USpringArmComponent* CameraBoom; 17 | 18 | /** Follow camera */ 19 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) 20 | class UCameraComponent* FollowCamera; 21 | 22 | //! IK_Foot Actor Component 23 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "IK_Foot", meta = (AllowPrivateAccess = "true")) 24 | class UCpt_IK_Foot* m_pIK_Foot; 25 | 26 | 27 | 28 | public: 29 | ASimpleFootIKCharacter(); 30 | 31 | /** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */ 32 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera) 33 | float BaseTurnRate; 34 | 35 | /** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */ 36 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera) 37 | float BaseLookUpRate; 38 | 39 | protected: 40 | 41 | /** Resets HMD orientation in VR. */ 42 | void OnResetVR(); 43 | 44 | /** Called for forwards/backward input */ 45 | void MoveForward(float Value); 46 | 47 | /** Called for side to side input */ 48 | void MoveRight(float Value); 49 | 50 | /** 51 | * Called via input to turn at a given rate. 52 | * @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate 53 | */ 54 | void TurnAtRate(float Rate); 55 | 56 | /** 57 | * Called via input to turn look up/down at a given rate. 58 | * @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate 59 | */ 60 | void LookUpAtRate(float Rate); 61 | 62 | /** Handler for when a touch input begins. */ 63 | void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location); 64 | 65 | /** Handler for when a touch input stops. */ 66 | void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location); 67 | 68 | void Sprint_Press(); 69 | 70 | void Sprint_Release(); 71 | 72 | void IKDebugToggle(); 73 | 74 | protected: 75 | // APawn interface 76 | virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; 77 | // End of APawn interface 78 | 79 | public: 80 | /** Returns CameraBoom subobject **/ 81 | FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; } 82 | /** Returns FollowCamera subobject **/ 83 | FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; } 84 | }; 85 | 86 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIKGameMode.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #include "SimpleFootIKGameMode.h" 4 | #include "SimpleFootIKCharacter.h" 5 | #include "UObject/ConstructorHelpers.h" 6 | 7 | ASimpleFootIKGameMode::ASimpleFootIKGameMode() 8 | { 9 | // set default pawn class to our Blueprinted character 10 | static ConstructorHelpers::FClassFinder PlayerPawnBPClass(TEXT("/Game/ThirdPersonCPP/Blueprints/ThirdPersonCharacter")); 11 | if (PlayerPawnBPClass.Class != NULL) 12 | { 13 | DefaultPawnClass = PlayerPawnBPClass.Class; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/SimpleFootIK/SimpleFootIKGameMode.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/GameModeBase.h" 7 | #include "SimpleFootIKGameMode.generated.h" 8 | 9 | UCLASS(minimalapi) 10 | class ASimpleFootIKGameMode : public AGameModeBase 11 | { 12 | GENERATED_BODY() 13 | 14 | public: 15 | ASimpleFootIKGameMode(); 16 | }; 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/SimpleFootIKEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 CatDark, All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class SimpleFootIKEditorTarget : TargetRules 7 | { 8 | public SimpleFootIKEditorTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | ExtraModuleNames.Add("SimpleFootIK"); 12 | } 13 | } 14 | --------------------------------------------------------------------------------