# Get a Vector3 to always have a radius of 1 from 0, 0, 0

Basically say I have a Vector3. I want to make it so that if the **origin is and always is 0, 0, 0**, how I can get it so the **Vector3 will always be a radius of 1** away from that point, but is still pointing in the same direction toward 0, 0, 0.

I'm pretty sure the way you would do this in a 2D plane is to draw a circle around 0, 0 and figure out the radius of that, then divide both the X and Y by that radius. I haven't tested that but it sounds like that is the way to go. **I don't know how I would do that in a 3D plane though.**

I'd imagine this is gonna be really complicated and the math this requires is gonna be crazy, but I'd imagine it's also just a copy-and-paste situation. Don't feel like you need to explain why it works if you don't want to.

In case you're wondering why I need this, I'm trying to create a mechanic that makes the Physics.gravity based on the player's collision's hit point and the transform of the player. The problem is despite my efforts the gravity keeps on getting set too strong, I just want to have this ran every few frames. If there's a better way to do it than this, I'd prefer that solution instead if you'd be willing to tell me!

I'd really appreciate any help, thank you for reading!

Okay, I've figured out a really ill-optimised temporary solution, here's the code:

GameObject emptyGravity = Instantiate(new GameObject(), temp01, new Quaternion()); emptyGravity.transform.LookAt(Vector3.zero); while (!Mathf.Approximately(Vector3.Distance(Vector3.zero, emptyGravity.transform.position), 1)) { if (Vector3.Distance(Vector3.zero, emptyGravity.transform.position) > 1) { emptyGravity.transform.Translate(emptyGravity.transform.forward / 100); } else if (Vector3.Distance(Vector3.zero, emptyGravity.transform.position) < 1) { emptyGravity.transform.Translate(-(emptyGravity.transform.forward / 100)); } } Physics.gravity = emptyGravity.transform.position; Destroy(emptyGravity);The Vector3 that I want turned into a Vector3 with a radius of 1 from Vector3.zero. It seems to work pretty well, but I'd imagine it is incredibly unoptomised. Do not put this in an Update loop, this is only ran in my code when the function is called, which is only in specific scenarios. When I ran this code additionally:

Debug.Log(Vector3.Distance(emptyGravity.transform.position, Vector3.zero)I practically only got "1" out in the console, so I'm gonna assume that it is working properly.

**Answer** by tormentoarmagedoom
·
Feb 02 at 06:16 PM

Hello are you just trying to determinate a "gravity" direction?

You know there is the LookAt funciton and the Normalize function?

Bye!

I already figured that out, I’m just trying to make it so that the point, relative to 0,0,0, would lie on the edge of a sphere with a radius of 1 and a centre at 0,0,0.

**Answer** by Captain_Pineapple
·
Feb 02 at 09:21 PM

Hey, well in general tormentoarmagedoom is right.
There is the function `Vector3.Normalize(YOURVECTORHERE); `

which will **return** the vector you feed in with a length of 1.
This is also nothing really "fancy or crazy math" as you described it. Well at least as long as you've heard of the theorem of Pythagoras that is. But nonetheless just use the function provided by unity.

in any case there is also the following possibility: Assume you have a `Vector3 testVector`

then you can always access the normalized version by `testVector.normalized`

.

this basically gives you a given direction with a vector length of 1, so the given point is basically on a sphere with radius 1 around the origin. (even though this description of yours is a bit fancy :))

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Find a point in space using Vector3 angles and Raycast 1 Answer

Applying direction into transform position 0 Answers

Can someone explain the math behind finding the velocity relative to where I'm looking? 2 Answers

Dot product not working when Enemy change its direction 0 Answers

[Kudan AR] (Markerless) Augmented Reality and Rigidbodies 0 Answers