# Calculate Distance From Forward Vector to Desired Axis Value

**URL:** <https://forums.unrealengine.com/t/calculate-distance-from-forward-vector-to-desired-axis-value/1606632>\
**Category:** Blueprint\
**Tags:** forward-vector, unreal-engine, question, Blueprint\
**Created:** [January 11, 2024, 3:09pm UTC](https://forums.unrealengine.com/t/calculate-distance-from-forward-vector-to-desired-axis-value/1606632 "2024-01-11T15:09:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Q-18S](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Q-18S](https://forums.unrealengine.com/u/Q-18S)\
**Post date:** [January 11, 2024, 3:09pm UTC](https://forums.unrealengine.com/t/calculate-distance-from-forward-vector-to-desired-axis-value/1606632/1 "2024-01-11T15:09:46Z")

</div>

Hello, I have been trying to create a function that creates a line trace a certain length but ends if it reaches a given Axis (Axis Value change constantly). The line trace starts from the camera forward vector and should end once it reaches the given axis value (end as in the length of the line trace not the function).

This way no what angle i look at the axis the line trace will adjust itself to reach that point.  
The question is how would

The Question: Is there a way to calculate the distance from the player/camera forward vector to the desired x axis in a 3d space?

 ![Screenshot (41)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/2/3925ab795ad384d394d30818d91d5b3525bc2573.png)

i can provide more screen shots if needed 🙂

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [January 11, 2024, 3:38pm UTC](https://forums.unrealengine.com/t/calculate-distance-from-forward-vector-to-desired-axis-value/1606632/2 "2024-01-11T15:38:37Z")

</div>

It’s a bit hard to make sense of this.

> [@Q-18S](#):
>
> The Question: Is there a way to calculate the distance from the player/camera forward vector to the desired x axis in a 3d space?

What is “the desired x axis” ?

Do you mean you want to trace forward until X = a certain value ?  
In this case, you are tracing towards a plane, defined by its X value.  
Look into this post maybe that’s what you are looking for

> [@Hard times getting mouse position in 2.5D platformer](https://forums.unrealengine.com/t/hard-times-getting-mouse-position-in-2-5d-platformer/1592560/2):
>
> You can use [Line Plane Intersection (Origin & Normal) | Unreal Engine Documentation](https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Math/Intersection/LinePlaneIntersection_Origin_Nor-/) to get mouse intersection on a given plane: Hope it helps.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 10, 2024, 3:38pm UTC](https://forums.unrealengine.com/t/calculate-distance-from-forward-vector-to-desired-axis-value/1606632/3 "2024-02-10T15:38:53Z")

</div>

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