I have a boat actor that has a simple collider shaped like a box. In play mode, I can get into it and walk inside of it. With water simulation, it floats and all is good until I get to the edges of the collider. Then, the player drags the collider across the water and the land. I’d like to prevent that. I’m not sure how to do it. When the player actor gets to the sides of the collider, it should stop, not drag the collider along. How can I do that?
But it only solves part of the problem: now the boat hardly moves at all. I need it to respond to the motion of the water from the buoyancy component but not to the motion of the player pawn. There must be a way to simply do that. In Unity, I’d tell it to ignore any collider input that has the player gameobject as its source, but I’m guessing Unreal will be very different.
Sounds to me like when the character is walking into a wall on the boat the character applies force to the boat in the direction the character is moving.
When the player is not controlling the boat why don’t you use the Set Physics Linear Velocity and Set Physics Angular Velocity nodes to 0, 0, 0 on the boats simulating physics mesh.
I’m new to Unreal and I didn’t know about that setting. I’ll try that. Thanks! If it works, it was exactly what I needed. I’ll try it and let you know.
@mindsurferdev Your answer solved most of it, but now the boat hardly moves at all. (I clamped rather than removed the velocity.) I still need the boat to respond to the buoyancy of the water, but still ignore the movement of the player. Basically, it should respond to some hits, but not others. There must be a specific setting for that, but I don’t know which one it is. I’ve looked it up, but not found out what it is. This matches the real world: if I’m on a boat, the boat responds to the motion of the water (and a little to mine, but let’s ignore that for now), but I’ll be moving in relation to the boat. Me moving to the edge of the boat, will not make the boat move forward. But it won’t stop the boat’s motion in relation to the water either.
Maybe multiplying it by -2 would work better I’m not sure
You can also try: Stopping the player’s impulse if the player is walking into a wall on the boat. So that on event hit you check the dot product between the player’s normalized velocity and the normal of the boat wall and if it is at a certain angle you won’t apply velocity to the player. You might need to figure out how to ignore the floor of the boat tho
Honestly, this option in Unity sounds great, I don’t think UE4 has this as I have faced a very similar problem and no one could help me either.
I’m about to try it now. I’m a bit worried about actually applying the force and then removing it as opposed to not applying it at all, but it should be only for one frame, so it should be okay. It may also be possible to do my “Unity solution” in Unreal in C++, but I must program this in Blueprints.