C++ Wallrunning and Crouch Help

Okay,

After a ton of Googling…I am officially…About the same, if not less, then where I started when dealing with how to accomplish these things (I am actually more ahead on the Wallrunning part). I am modifying the FPS Character template to be more fully featured. Currently upgraded some of the movement (need it faster for the game a friend and I are working on) and added a stamina system. But I am utterly stuck with implementing a; Wallrunning ability (like the CoD BO3’s one), and a Crouching ability.

For the Wall Ride part:

  • I have the raycast in effect inside of a function
  • That function is inside of the Tick()
  • When it hits a wall with the FName == “RunnableWall”, it hits correctly and notices the wall
  • Then…I don’t have a clue. I have looked around, but it ambiguously says; use a Physics Force to push the player towards the wall, or lock the player’s axis to allow the Wall Ride which really gives me no help whatsoever

For the Crouching part:

  • I have an BindAction that’s connecting the “Crouch” button (C) to a Crouch function
  • I have tried; CharacterMovement->bWantsToCrouch, OnStartCrouch(), But nothing.

So, I’ve been pretty much stuck as a result. On a good note, I think I’ve figured out what the main problem is I just don’t know the specific functions, variables, etc. needed for this. All the help has been rather ambiguous in that it’ll mention what to do, but it won’t even as much give you the classes to look at (more helpful would be some of the functions to look at…So I could at least API/Google reference them to find a solution).

It also seems that there are WAY too many answers…For BP. But not anywhere near enough for C++, and it’s really starting to grate on my nerves. So any, actual, help would be appreciated. I’ve been driving myself up a wall with nothing to show so far.

Okay, on an update, I’ve figured out how to crouch, if anyone wants a reference to it (to help anyone out, cause God-knows how difficult it was for me to find a solution), check HERE.

Also, if anyone want a simple toggle-crouching effect, set up the crouch button as usual, and do something like this:

void AXXXXXCharacter::ToggleCrouch()
 {
	 isCrouching = !isCrouching;
	 

	 if (isCrouching == true && CharacterMovement->IsMovingOnGround())
	 {
		 Crouch();
		 GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Blue, "IsCrouching = true");
	 }
	 else if (isCrouching == false)
	 {
		 Stand();
	 }
 }

And standing is really as simple as:

 void AOperationBadassCharacter::Stand()
 {
	 UnCrouch();
	 GEngine->AddOnScreenDebugMessage(0, 5.0f, FColor::Blue, "IsCrouching = false");
 }

Now, if anyone could provide any help for Wall Running using C++, I would appreciate it.

The issue with WallRunning is that it’s not something that’s provided as part of the Unreal Character Controllers (at least not as far as I know). As you saw with Crouching, some common functionality is taken care of for you but wall running is not one of these things, so there isn’t really “an answer” as the implementation depends heavily on your game mechanics (do you stick to the wall and run around freely, is is parkour style, can you jump off the wall etc).

I would certainly start by looking at adding a force to push against the wall or getting the actor to move across a spline rather than being “free”.

As for the BP vs C++ thing - It’s true that there are a lot more BP examples out there, but all Blueprints expose something that you’ll also find in C++ (as BP class are just an extension or exposure of the C++ classes). If you find something in BP that you like, you should be able to re-create it in C++ by finding the matching functions and implementing the same logic (the github source is very useful for this!)

Thanks for answering back.

The force push?..How would one go about this?

(btw, I’m still rather new to C++ UE4 coding. But I’d rather not use BP and I’m carrying over from Unity, so this project I’m working on (with a friend) is 2-fold. It helps me understand how to program with UE4 and C++. So any specifics (classes, functions, etc.) that might be helpful to look at, I would appreciate it.)