# Vector not enough accurate?

**URL:** <https://forums.unrealengine.com/t/vector-not-enough-accurate/246794>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 22, 2021, 2:39pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794 "2021-08-22T14:39:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hdubs37](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hdubs37/32/88714_2.png) [@Hdubs37](https://forums.unrealengine.com/u/Hdubs37)\
**Post date:** [August 22, 2021, 2:39pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/1 "2021-08-22T14:39:57Z")

</div>

Hello Guys.

I’m a beginner on UE and i’m facing a problem. I am probably not treating this issue as I should I guess so i’m asking your help

I followed a tuto to create a simple turret. Now I am trying to improve it.  
I am trying to play a sound WHEN my turret is moving.  
So my turret detect a target, then align to it ( by comparing “find look at rotation” between both actors and “get World Rotation” of the turret. When it is different, it align to it. That is working.

When i am far from the alignement, everything is OK. But when my turrent is aligned to the target, and the target is moving, I can’t find a way to detect the micro movement. All i have done is not accurate enought.  
I tried to round the rotation vector and everything, but this is not accurate enought. Whether it is too round and i can’t detect the micro movement, whether it is not enough rounded and the alignement is always different. Look

 ![vectors_screen](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/a/9a8705f910941675c78d0989f44c9563c1c3e0fe.png)

The final print string is telling me if the two vectors a equal. So the turret align, I micro move, it micro re align, and sometimes it says TRUE, sometime it says FALSE, because it’s not accurate enought. I also tried with the “DOT” function but it’s not beter

How should I do ?  
Thank for those taking the time to read me. Really.

Edit : here are the values returned by “Find look at Rotation” and “Get World Rotation” when both are align, there is a little difference

![vectores3](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/6/766214f143141170f8c9ee31b4b0832bf1a8a592.png)

---

<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:** [August 22, 2021, 5:19pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/2 "2021-08-22T17:19:08Z")

</div>

Don’t play the sound depending on the difference, play the sound for as long as you have to run the rotation code. Then stop it, when the rotation code stops.

For a micro rotation, the system won’t get a chance to play the sound.

---

<div class="post-metadata">

**Author:** ![Hdubs37](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hdubs37/32/88714_2.png) [@Hdubs37](https://forums.unrealengine.com/u/Hdubs37)\
**Post date:** [August 22, 2021, 5:42pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/3 "2021-08-22T17:42:20Z")

</div>

Thank you for your answere Clock !  
I’m not sure this will work, as the code for upgrading the turret rotation is running in continue since there is a target in the sphere of detection… 😕

It’s made like this :

- Find a target ( via sphereOverlapActors)
- then it align to the target. So the sound is playing in continue if I do that

---

<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:** [August 22, 2021, 6:24pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/4 "2021-08-22T18:24:31Z")

</div>

How about only playing the sound if the difference is greater than a certain amount. If it’s only moving in Z, well, that’s just a float. If it’s moving in all 3 axes, then you can use:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/4/a417b88f008a4f61806fe1c5944256582801e8e9.png)

Or something like that ( just off the top of my head ).

---

<div class="post-metadata">

**Author:** ![Hdubs37](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hdubs37/32/88714_2.png) [@Hdubs37](https://forums.unrealengine.com/u/Hdubs37)\
**Post date:** [August 22, 2021, 6:54pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/5 "2021-08-22T18:54:07Z")

</div>

Thank you for having take time to try something, appreciate it !

Unfortunately, doesn’t work either.  
The result after the ACOSd, when i’m moving ( so when the turret is aligning) varies from 0 to 0.027976, and when it is aligned and I don’t move anymore, the result is a number beetween 0 and 0.027976 ( and it can be 0.027976 too) so i can’t test this number because it can happen both when it’s moving or when i’m still

Can’t find an easy way to do this 😕

 ![a](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/4/24fc3a802177e7f6880c9fcff6fdcb68c30395b2.png)

 ![b](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/e/be39b715a0e2c753afe529fd41f41b3afec8938e.png)

 ![3](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/d/6d87e531a3f0fc8a271e864384a4b687703e8985.png)

---

<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:** [August 22, 2021, 7:00pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/6 "2021-08-22T19:00:30Z")

</div>

I think it’s because you’re moving on tick. A real turret wouldn’t move like that, it would wait until the player is out of scope, and then move.

So keep everything you have on tick, but put a test at the start. Don’t even bother moving until the result of the test is \> 5 degrees.

And I have another idea, gimme 5…

---

<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:** [August 22, 2021, 7:04pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/7 "2021-08-22T19:04:41Z")

</div>

Ok, try that previous idea, but there is also this:

Measure the different between target locations. When you look at the player, you can extend a vector in front of the gun ( fixed distance ). Next time you look, extend the vector again, and look at the distance between them:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/0/e0c060fb58f4802a4b446fc2e0deef368c9b9e6c.png)

I think you will have the same problem if you run it every frame BTW, but at least you’re measuring a larger distance.

---

<div class="post-metadata">

**Author:** ![usa423](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/usa423/32/918773_2.png) [@usa423](https://forums.unrealengine.com/u/usa423)\
**Post date:** [August 22, 2021, 7:47pm UTC](https://forums.unrealengine.com/t/vector-not-enough-accurate/246794/8 "2021-08-22T19:47:57Z")

</div>

This looks really cool, will have to try a turret tutorial.
