Projecting Vector using dot product help

Hi there,
So my brain is completely fried and I seemed to have forgotton basic vector math.



red is unreals trace.
yellow is my indication how far it should go.
Green is the target “line” the rays should extend to.

What I am trying to accomplish is basically my line trace projecting back to the orthogonal of the vector between the player and the object. It should shoot rays as far as the green plane. I am using the dot product and I am not sure where I am going wrong. If anyone has a solution it would be greatly appreciated! :slight_smile:

I would try putting everything on the click event for starters. At the moment, there’s no guarantee what you’re getting from tick is synchronized with the other stuff.

tick is only a debug arrow i am drawing temporarily. The actual math happens without any tick.

1 Like

You’re right, sorry :slight_smile:

Hey, I don’t get what you’re trying to do, but you could use a “line plane intersection” node, if you want to do what I think you do.

3 Likes

I’m not familiar with line plane intersection so I’m not sure if that’s what you want, but here’s how to do it using trig

Effectively all we do is divide distance by cos(theta), theta being the angle delta between the axis and player rotations. For Y we have to subtract 90.

Resulst:

To clarify, here is what I am trying to do.

I want to shoot rays from cam and it should go into the direction until its perfectly orthogonal between the red vector and not past that.

image

like so. However may rays seem to be too short. I notice that the rays I fire are orthogonal to the target however what I want to ensure is that the rays going from p to fired ray and ray to cam are orthogonal, not the fired ray to the point p

currently, I get these results:

It has so many applications that, once you know how it works, there’s no looking back. Some examples:

1 Like

this looks like something that would solve this, ill check it out and let you know :slight_smile:

These functions are built in allready.




(edit added blue lines)

2 Likes

here is another one.


2 Likes


can you explainthis bit?

1 Like



dot product + acosd is a fixed formula for getting the angle degrees to me ,I don’t know why it can do that though.I just know how to use it.

1 Like

this makes sense and is actually pretty simple, not why my intuition didnt grab that! Thank you!

1 Like

The dot product of two unit vectors is the cosine of the angle. It doesn’t need to be turned into an angle then cos() again.

To get the length we can just do adjacent / dot product = hypothenuse.

1 Like

I didn’t know this before,well now I know :joy: .thanks

1 Like

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