Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to stop the player capsule from bouncing off corners? (Pictures included.)

alt text

alt text

How can I stop this from happening? If I could get him to instead bounce straight back down, that would be good. But what I really want is for him to smoothly slide to the side of the block, and keep the same upward momentum, much like what happens in Super Mario Bros. for example. (Yes, in SMB if you jump close to the edge of a block, it won't break, you will slide to the side, like in the image below.)

alt text

Product Version: UE 4.15
more ▼

asked Aug 08 '17 at 04:58 AM in Using UE4

avatar image

179 14 19 30

avatar image Darlos9D Dec 24 '17 at 12:48 AM

Excellently illustrated. I'm trying to figure out the same thing. I see a couple similar questions being asked but none of them have answers either.

avatar image JerichoBLT Jan 04 '18 at 02:00 PM

Hey, thanks! Glad to hear it. I still haven't figured out a perfect fix, but I have found some plausible workarounds:

In the character movement component, there are these two settings: "Braking Decelerating Falling" and "Falling Lateral Friction." Setting one of those to some higher value seems to stop the capsule from bouncing away. However there are two problems with this: One, it screws up the air control I liked, I.E. the character seems to stop too sudden. (I still don't completely understand it.) And two, the player doesn't get enough height after hitting the edge of the block.

So, to fix the air control, we might have to find an alternative way to add movement input while airborne. So far the best solution I've found is to disable input altogether after jumping. It works if you want your game to have no air control, like in Assassin's Creed, or Uncharted for example, but I wanted my game to feel more like Super Mario Bros.

avatar image Darlos9D Jan 05 '18 at 02:48 AM

I'm at the point where I'm about to just get into the actual character movement component code and roll my own direct adjustments and solutions to the way this is handled. I'm making a smash bros esque "platform fighter" and I too want some definite air control without the character bouncing off of surfaces like crazy. Sorry if you're not a C++ programmer though. I'm not sure if whatever I come up with will be anything I'll be able to easily explain.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Alright, unfortunately I don't think there's a blueprints answer to this, if that's what you're asking. However I've done some digging around and think I can at least explain how to do it through C++ for posterity.

So to start with, lets get right to the root of the "problem," which is this blasted code in the PhysFalling() function in the UCharacterMovementComponent class in CharacterMovementComponent.cpp:

alt text

The arrow points at the line where velocity actually gets set to the new "bounced" velocity. There's also an identical line down at line 4045 that does the same thing in the case of a collision happening after the first collision adjustment on 3995. So, that's our culprit. The most straightforward solution is to comment out lines 3989 and 4045. Of course, we don't want to do that in the engine code. So we have to make our own character movement component that inherits from UCharacterMovementComponent and overrides PhysFalling(), and have our character class use it instead. To do this we have to make sure our character class is using the FObjectInitializer constructor, and then we can follow this guide here.

And that's that. The results of the call to ComputeSlideVector() at line 3983 actually does a halfway decent job of "slipping" the character up and down past inclines and edges, like the result we're looking for. There's a bit of "friction" to it and I don't know if that's some kind of actual material friction or just a peculiarity of the calculations, but its a lot better than bouncing off in crazy ways. I'm sure any clever developer can see their way to more robust solutions and alterations to this, but I think this is a pretty solid starting point. Hopefully this will help down the road.

EDIT: I almost forgot. One negative result of this is that hitting a perfectly horizontal ceiling while traveling upward will have the character just kinda "stick" against it until gravity pulls their velocity back down. This can be circumvented by implementing a check to see if the impact normal is pointing straight down. (which is to say, its Z parameter is rougly -1.0) If it is, just set the Z parameter of Velocity to 0. You can even add more wiggle room to this check, causing the engine to treat slightly angled ceilings like they're flat ones also, if you don't want the character "slipping" up shallow ones.

darndeflection.png (50.2 kB)
more ▼

answered Jan 08 '18 at 12:52 AM

avatar image

1 1 2

avatar image JerichoBLT Jan 16 '18 at 09:48 AM

This sounds like what I need. :) I don't even mind the sound of him not bouncing down from the ceiling, I actually wanted that for my game. Lol

I've used programing languages before, but I haven't delve into using C++ with Unreal yet. I'm a little busy with other things right now, so give me some time. I'll be sure to try it out.

Thank you very much.

avatar image JerichoBLT Oct 27 '18 at 05:02 PM

Hi, Darlos9D. Are you still there? Sorry, I ended up taking a looong break from developing my game, but I'm back now, and I'm ready to try out the solution you provided me. : )

But I'm having loads of trouble. How do I do the part where you said: "So we have to make our own character movement component that inherits from UCharacterMovementComponent and overrides PhysFalling(), and have our character class use it instead. To do this we have to make sure our character class is using the FObjectInitializer constructor, and then we can follow this guide?"

I'm sorry, but I'm just not sure how to start. Do you think you could help me out one more time? :3 (Or someone else.) I'm not completely clueless, so it shouldn't take too long.

By the way, my project was originally created with the blueprints template. Is that okay?

avatar image Darlos9D Feb 21 '19 at 03:05 AM

I don't think you can do it with blueprints I'm afraid. The guide I linked to is the only way I could find to do it, and requires you to do work in C++. Sorry :(

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question