Just wondering if there is an alternative to this “fix” that uses the “Tick Event” presented in the class " Forcing Character Collisions" , now with the official release of the Unreal Engine 5.
It looks really hacky indeed. im interested also, what the proper solution would be.
I think I figured this out, hopefully someone will correct me if I’m wrong.
The character doesn’t have most physics enabled by default, and only does a simple sweep test when moved by the character controller. To enable always-on physics, you must set your character collider’s “simulate physics” to true, and you will likely want to lock rotations under physics constraints so the character doesn’t topple over.
EDIT: Nevermind, this disables the character movement class. A forum post I found recommends against simulating physics on the character collider Character movement at Simulate Physics - World Creation - Unreal Engine Forums
When I read about CCD (Continuous Collision Detection) I thought I was in the right direction to some sort of fix, but it didn’t work either. I assume CCD is used only for better detection of fast moving objects, like projectiles.
I too would be very interested in a better solution to this, it seems like every project would need this if they expect sensible physics collisions with characters on the XY axes.
Also very curious how/why collision seems to work just fine with the platforms moving vertically. I assume it’s something to do with gravity?
@Felbrax
Your assumption is mostly correct. As the documentation indicates, it’s also used to prevent multiple overlap events from firing in a single frame.
@timoxley
Basically, the character is a kinematic actor - meaning other objects will collide with and bounce off of it, but it cannot be pushed. So the character behaves more like a wall (which is static) rather than a dynamic physics object.
Also, the character’s movement component contains logic that emulates physics, like applying ‘artificial’ gravity for instance (artificial in the sense that it isn’t based on gravity forces applied by the global physics system). This logic also detects objects that are directly below the character by doing a simple sweep test from the center of the character downward. I’m over-simplifying here, but basically if a walkable ‘floor’ is detected, the character’s position is corrected to the appropriate location. This of course only occurs in the Z direction, so an object moving along one of the horizontal axis isn’t handled in the same manner (probably to avoid expensive sweep tests in every direction around the player).
Hopefully that makes it a little clearer why the ‘hack’ is necessary. Keep in mind that you can always subclass UCharacterMovementComponent
and modify the emulated physics as you see fit. That might actually be a good exercise for you to try when you get more comfortable with the engine.
So I implemented the forcing of character collisions in the BP but after the change, the character is no longer able to rotate to face the direction of movement.
Am I missing something or is this a side-effect of the change?
Ok, I guess I should have waited until the end of the lecture before posting
Oof. Was about to post about it too. I Better watch to the end
I covered it in-depth under this post: DO NOT use Event Tick, use Event ActorBeginOverlap - Unreal Courses / Show - GameDev.tv.
Essentially he breaks the game by using the Event Tick node because it runs every single frame instead of when an actor collides with another actor. The one you need to use is “Event ActorBeginOverlap”. The code for this is a lot simpler.