I can't get a block to work in this situation.

The player character needs to be blocked from going too high in the screen.

A box collision is in the camera actor bp that runs parallel to the player in this example. And its set to the camera actor, and it is set to block everything.

The box collision in the player pawn is set to pawn and set to block the camera actor, yet it does nothing.

This is a simple config but I have tryed many things, like custom collision channels for the two boxes even. What am I doing wrong here? thanks!

1 Like

Did you code the pawn from scratch? I think only character blueprints observe blocking volumes by default.

2 Likes

Yes I did. Ahh I did not know that. But If I tried to make or use a character bp it kept pulling me down even when I turned the gravity off.

@ClockworkOcean just so you know, you were correct sir, I have tested with a character bp and got it to work so I will mark your first comment as the answer. But I need you to help me some more for this if you can I would appreciate it. It works but has a few issues. Here is a video with updated results. In the video I have 3 questions for you.

  1. Notice if I press up I go up, but the moment I let go gravity pulls me down although it is off. I want it to just not come down if I press up.

2.@ 14-18 seconds notice the weird nudging effect if I am as far to the right as I can be blocked by a box collision then I press right and it nudges.

3.@ 28 seconds I call this “hole in the box collision”. These are two box collisions, the top and the left. There is no hole or gap there to cause such an effect yet it is happening. And once it gets through there and touches the top of that collision its like my speed is increased to the craft, kind of like when you beat a stage in one of these shipscroller games and the vehicle moves forward at an increased pace until it is off the screen.

Thanks again for the help Clockwork!

Could you not just limit the maximum height, your unit can go. f.e. with a compare node?
You could create a variable with the maximum height, then get your current height, and compare it with max height, and if its equal or higher than max height, set your current height/the position of your character down to the max height.

For your unwanted gravity, if your char has the character movement component, you can switch to flight mode, if you created it from scratch, check everything in your char, if it is affected by gravity, or turn gravity off - which would be almost the same, what the flight mode does.

2 Likes

Yes, like @Suthriel says, this character thing was just checking that was the problem. Once you know it is, you can just limit the movement in the pawn with the code.

1 Like

Ok I assume you want me to check that height before I move the vehicle.

I am seeing some promise using this method, when just trying to move up down left or right. Although the diagonals have made things more difficult.

To get the left and right barriers, the only thing I could come up with here is to get the distance to the player character VS the camera actor as the camera actor moves parallel to the player at the same Y speed. So if that distance is greater to or equal a certain number use it to set left or right barrier.

Right now I notice left and right getting stuck for some reason.


That was easy, Thanks for all your suggestions.

But I honestly still don’t understand why the engine can’t do blocks if it is not a character bp.

I wondered about this method before but never actually tried to use it. I wonder if I’m trying to limit at the correct places though. My method of movement in this example is add actor world offsets fed by Event Tick.

And doing checks before these offsets. But is there somewhere else you would recommend limiting this movement? Thx again for all the help Clockwork!

I don’t know what’s in those barrier check macros, but the obvious way to do it, is to clamp the vectors you’re using for the offset :slight_smile:

2 Likes

Here is the one for the left.

Clamp the Vectors with this node right here?
Image8

Can you explain this more?

I don´t know, how you actually move your char, but usually those blocking volumes work and block just fine - if they are set up correctly, and the used movement method is told to respect the block.

F.e. some nodes require you to set a bool to true to start/respect blocking:

But you don´t need them in the sky, if you just limit your max height ^.^ Just follow what @ClockworkOcean says, because (in my eyes) he is a coding god :slight_smile:

2 Likes

Adding offset may not be the best way to do it. Aiming for a target height, and clamping is easier

image

( ignore the actor X and Y, keep what you have for moving it along )

height

( mediocre level coding :slight_smile: )

1 Like

I read somewhere else that you need to enable sweep to get block to work sometimes.

Ok.

I hear you, both he and Everynone have been a lot of help to me. I hope to one day know just half of what these wizards know about coding and Unreal. And thanks for your help as well!

Thanks Clockwork for the node diagrams and the video! I will try to implement this!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.