# How to make minimal firing range for units in a game?

**URL:** <https://forums.unrealengine.com/t/how-to-make-minimal-firing-range-for-units-in-a-game/1734272>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [March 6, 2024, 5:39pm UTC](https://forums.unrealengine.com/t/how-to-make-minimal-firing-range-for-units-in-a-game/1734272 "2024-03-06T17:39:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [March 6, 2024, 6:21pm UTC](https://forums.unrealengine.com/t/how-to-make-minimal-firing-range-for-units-in-a-game/1734272/2 "2024-03-06T18:21:22Z")

</div>

If your map is made of squares, you could build trenches taking [a square of space on a map](https://forums.unrealengine.com/t/projectile-trajectory-and-ground-level/674611/21). Similar to a chess board you then can compare square coordinate of the soldier to square coordinate of the trench (say X3, Y7 is a place on the map marked trench.). In this case I’d have a spawner / subsystem keeping track of what is spawned and where, mapped to those coordinates on a property.

You could also add overlapping collision box to the trench actor, so that when soldiers walk into the invisible box (overlap) they are notified that they can not throw a grenade.

Other option is to measure distance between two locations. You could set Z on the location vectors to 0 to measure only horizontal distance:

```auto
const FVector LocationSub = FVector(133.f, 155.f, 20.f) - FVector(33.f, 75.f, 10.f);
const float Distance = LocationSub.Length();

```

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-make-minimal-firing-range-for-units-in-a-game/1734272)._
