# find vector3

**URL:** <https://discussions.unity.com/t/find-vector3/137789>\
**Category:** Questions & Answers\
**Created:** [May 5, 2015, 9:50pm UTC](https://discussions.unity.com/t/find-vector3/137789 "2015-05-05T21:50:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aanimation](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/aanimation/32/465276_2.png) [@aanimation](https://discussions.unity.com/u/aanimation)\
**Post date:** [May 5, 2015, 9:50pm UTC](https://discussions.unity.com/t/find-vector3/137789/1 "2015-05-05T21:50:49Z")

</div>

![45788-how-to-find.jpg](https://europe1.discourse-cdn.com/unity/original/3X/a/9/a968b125387b520904d0b32801a72c700e2895ba.jpeg)

anyone can help me?

how to find vector3 value about this pict?

---

<div class="post-metadata">

**Author:** ![NoseKills](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@NoseKills](https://discussions.unity.com/u/NoseKills)\
**Post date:** [May 5, 2015, 9:57pm UTC](https://discussions.unity.com/t/find-vector3/137789/2 "2015-05-05T21:57:33Z")

</div>

float range = 3f;  
Vector3 Tp = target.transform.position;  
Vector3 Pp = player.transform.position;

```
			// vector from target to player
			Vector3 targetToPlayer = Pp - Tp;
			// vector with same direction as "targetToPlayer", but length of "range"
			Vector3 targetToPlayerWithRangeLength = targetToPlayer.normalized * range;

			// start from target and come towards player the "range amount".
			Vector3 positionOfSpot = Tp + targetToPlayerWithRangeLength;

```

---

<div class="post-metadata">

**Author:** ![Sprawl](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/sprawl/32/244023_2.png) [@Sprawl](https://discussions.unity.com/u/Sprawl)\
**Post date:** [May 5, 2015, 9:57pm UTC](https://discussions.unity.com/t/find-vector3/137789/3 "2015-05-05T21:57:39Z")

</div>

First, you need to get the vector3 of the orientation towards the target.  
After that, you will need to get only the part up to the circle around the target.

To get the orientation, simply substract them from one another :

```
Vector3 orientation = (target.position - player.position);

```

Afterwards, substract the value of the range from it, like so :

```
//Get the orientation of previously found vector
Vector3 GreenVector = orientation.normalized;

//Get the lenght of the previous vector minus the range
GreenVector = GreenVector * (orientation.magnitude - range); 

```

That should get you the green vector on the picture.

EDIT: Now, if you want the position of the point, simply add the player’s position to GreenVector.

```
Vector3 DesiredPosition = PlayerPosition + GreenVector;

```

---

<div class="post-metadata">

**Author:** ![aanimation](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/aanimation/32/465276_2.png) [@aanimation](https://discussions.unity.com/u/aanimation)\
**Post date:** [May 6, 2015, 12:43pm UTC](https://discussions.unity.com/t/find-vector3/137789/4 "2015-05-06T12:43:40Z")

</div>

if(hit.collider.gameObject.tag == “Tower”){  
Transform tower = hit.collider.gameObject.transform;

```
					Vector3 Tp = tower.position;
					Vector3 Pp = this.gameObject.transform.position;
					
					Vector3 targetToPlayer = Pp - Tp;
					Vector3 targetToPlayerWithRangeLength = targetToPlayer.normalized * rangeShoot;
					
					Vector3 positionOfSpot = Tp + targetToPlayerWithRangeLength;
					target.position = positionOfSpot;

					Instantiate(marker, positionOfSpot, Quaternion.identity);
				}}

```

hi All, thanks for responses, working perfect 🙂

terimakasih (bahasa)
