# Unreal Engine Blueprint: How to calculate the angle parallel to a moving face? How to calculate the tangent?

Hello guys,
I’m having a problem.

I’m shooting a projectile.

When it collides with an object, I’m creating another object parallel to it.

Currently, I have it set up like this:

Hit Normal -
Get Yaw Pitch From Vector - Pitch (Y) - Subtract 90 degrees - And I pass that value to the object I’m going to create… Y rotation.

But it doesn’t work for all angles.

I tried other functions where I subtracted 90 degrees or 150 depending on where the shot was coming from,
but it doesn’t work well.

Would it be ideal to calculate the tangent?
How could I do that?

Try this:

1 Like

I tried to do it but it didn’t work very well
hit the box floating

and appeared behind me
I couldn’t find the position or the rotation

The spawn location should be the impact point. For the rotation use the resulting rotator of the Make Rot from XZ node: Z would be the impact normal and X the direction of the projected vector.

1 Like

I think it still doesn’t work, they are all looking up

Please show the entire BP, including what is passed to the nodes.

1 Like

I have a tag
just craft that item on platforms (air or ground)
then i do what you say

There are more things, but they are asking the character for the maximum number there is, if there are 3 destroy the first one
have a time of self-destruction, ect.

but I think it does not affect the logic

the objects are in 2d, I only need their XY, I think not Z?
I don’t need its depth right?

What direction is your camera looking? -Z (top down), +X, +Y, etc.

1 Like

in normal inpact , I did a make rot from X , and it did ok , but it created them at 45 degrees ,

In the end I went to the object and I turned it 90 degrees and now when it is created it comes out perfect

I really don’t like the solution, by code I should be able to create it at that angle, and not twist the object, but well for now it works fine, if there was a better solution I would like to know it

I think it’s looking to the right, on the X axis.

in normal inpact , I did a make rot from X , and it did ok , but it created them at 45 degrees ,

In the end I went to the object and I turned it 90 degrees and now when it is created it comes out perfect

I really don’t like the solution, by code I should be able to create it at that angle, and not twist the object, but well for now it works fine, if there was a better solution I would like to know it

You have to either adapt the math or your assets to make them work together. No code will ever guess what side you want your actors to face.

If you could tell me what direction the camera is facing (X + or -) and what side of the actor you want facing the camera then I could be of more help. It could be as simple as this:

2 Likes

the character only moves in X Red,
and the objects rotate in Y , it is a 2d game
the character moves infinitely to the left or right ±
objects rotate in Y only

Ok.Try these two and pick the one that orients the newly spawned actor how you want it to:

MakeRotFromYZ:

MakeRotFromXZ:

1 Like

Now it works perfectly, thank you very much! seriously, thank you very much!

1 Like

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