# How to get the hit location of sphere trace in World Coordinates

**URL:** <https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908>\
**Category:** World Creation\
**Tags:** line-trace, world-space, unreal-engine, Blueprint, question\
**Created:** [June 14, 2023, 11:42am UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908 "2023-06-14T11:42:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lowenfas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lowenfas](https://forums.unrealengine.com/u/Lowenfas)\
**Post date:** [June 14, 2023, 11:42am UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/1 "2023-06-14T11:42:41Z")

</div>

I have some blueprints scattered across my map and in each one they do some sphere traces, if the trace is successful then it’s supposed to drop a tree at that location.

The problem is that the OutHitLocation is given in local space, I tried to add the BP actor location to the OutHitLocation which almost worked BUT most of the blueprints are rotated so that also throws off the placement of my trees.

There should be an easy way to get the local vector in that BP and just convert it to world space, but I can’t figure out how.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 14, 2023, 12:07pm UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/2 "2023-06-14T12:07:29Z")

</div>

It already is world space. Can you show your code?

---

<div class="post-metadata">

**Author:** ![Lowenfas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lowenfas](https://forums.unrealengine.com/u/Lowenfas)\
**Post date:** [June 14, 2023, 8:15pm UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/3 "2023-06-14T20:15:26Z")

</div>

The first pic is my sphere trace that outputs the location of the hit and sends that to my MakeTree function.

 ![Screen Shot 2023-06-14 at 4.05.48 PM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/1/3b1d0213b8722b4615d86ceaf58898ea65a59ebf.png)

This second pic just shows that the only thing my MakeTree function does is add an instance as the same location that the sphere trace outputs.

 ![Screen Shot 2023-06-14 at 4.06.10 PM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/6/566d19acd29e010b2fb758be585f344e1b4d4192.png)

I can confirm that IF I subtract the OutHitLocation by the self Actor location and use that value in the MakeTree function AND the BP is at 0, 0, 0 rotation then it does create a tree exactly where it is supposed to.  
When I run the code as it is in the picture (without subtracting the self ActorLocation) then it spawns the trees waaaaaay off.

I think in explaining this I even confused myself, let me know if you need any more info/screenshots.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 14, 2023, 8:35pm UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/4 "2023-06-14T20:35:29Z")

</div>

I think the problem is your ‘add instance’, that is expecting a local coordinate, and you’re giving it world.

Why don’t you have this?

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/7/7b7879bebc66e454bfcee4764c4c23c55c03c86a.png)

Lower engine version?

PS: If you have to stick with that node, just say, and I’ll show you how to convert to local space.

---

<div class="post-metadata">

**Author:** ![Lowenfas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lowenfas](https://forums.unrealengine.com/u/Lowenfas)\
**Post date:** [June 15, 2023, 10:47am UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/5 "2023-06-15T10:47:32Z")

</div>

Not sure why I don’t have that option BUT it turns out I have another node called “Add Instance World Space” and that did the trick.

---

<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:** [July 15, 2023, 10:48am UTC](https://forums.unrealengine.com/t/how-to-get-the-hit-location-of-sphere-trace-in-world-coordinates/1198908/6 "2023-07-15T10:48:30Z")

</div>

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