How to get the angle of a Hit surface?

Hi, in order to determine if my character Hits a wall or the ground, it would be great to be able to get the angle (or rotation) of the BSP surface. Is that possible?

Hey Albert,

To answer your question, I’m using the example I provided in the other question you had [HERE][1]:

Use this to Trace Forward:

Use this to Trace Down:

You could hook up the Append Nodes to print the X, Y, Z values for the Wall/Ground if you want (I just wanted to know if I was hitting a Wall, Ground or if I was in Air).

-W

1 Like

That’s an epic help, Wes, thank you very much.

I’ve setup a system like yours (from your explanation in the other thread I’ve understood that is a good a idea to use a trace for this instead of collision events).

From printing I see that this system nearly always points correctly if character is against a wall or on ground (or in air), even in ramps, which is great. The “nearly” is because of edges of platforms, but once I implement another stuff for edges treatment that won’t be a problem.

I had built a more complex rebounding effect for when colliding a wall, and when trying to implement it here I get puzzle. The effect done was to Launch Character (overriding all velocity) with its new velocity being its “Character Movement”'s old “Velocity” with Y multiplied by -1, and the whole vector multiplied by a number between 0 and 1 (so it seems that with the impact the character looses energy).

This rebounding thing worked with Hit events (the problem with Hit events, so, was the problems of knowing if it was in ground or against wall, which your last post has solved), but this effect doesn’t work in the current tracing setup.

*I have to break the comment into two.

What puzzles me is that if I print the Velocity that is inputed into the rebounding Launch Character function both in the Hit and the tracing setups I get different values for the Velocity (but the setup for that Launch Character function is exactly the same, and node debugging shows it’s executed as expected in both cases!); in the Hit setup I get a velocity with X,Y and Z values as expected, but in the tracing one everything in 0 expect of Z, so the character just gets moved up (so it doesn’t rebound after wall contact). And it just prints if the character is already against the wall, even though there’s no Branch between Launch Character and the Print String!

I’ve analized both setups carefully, but as said on both the Launch Character functions are identical and executed when expected (checked out with Blueprint node debugging). I first thought it could be something on Tick, but tried this in Begin Play with 0.05 delays so it was repeated with time like if it was Tick and the same thing happens.

Any ideas on how to solve this? Something is distorting Launch Character function or Character Movement componet Velocity variable.

Hi, I’ve marked in bold something in the last comment, from observation it seems like if the trace didn’t update often, because it only marks as hitting when the character had already been standing against a wall before the character is pushed by another one against that wall; if it’s more distant (so the trace line not touching the wall before being pushed) no hitting from tracing is communicated.

The fact is that I can’t understand why the tracing wouldn’t be updated at each frame (but more slowly) being called by Tick.

Hi again, here I show a way to detect if the character is colliding with wall or ground when Hit event is processed. This gives the expected results: the bool filtering with “Don’tProcessHitAgain” prevents having multiple undesired Hit calls at a single time (which happened before against walls, colliding many times at once). I think is better to set up this in Hit instead of in Tick calls with tracing for performance.

It works even in ramps, the only case in which it isn’t good yet is in the fact it detects ceilings as grounds, but a simple comparison between character’s mesh’s center of mass and the impact point Z locations would be enough to filter it as wall or as a ceiling, depending on how one wants to set it up.

As far as I’ve tested it seems to work nicely with characters in weird, wild rotations like ragdolls.

I’m glad you were able to find a suitable solution, there are different ways to accomplish the same thing, by experimenting you’ll find what works best as is the case here. Hopefully this will help someone else going down the same path.

-W

Thanks again to you for the tracing example, messing up a bit more with traces I think they’ll be suitable for some AI navigation stuff I’m planning, for example.