How to make something like a point effector 3D?
Hi,
I was experimenting a bit with Unity and I was trying to find out whether there is a point effector 3D, or something to use an object as a center of gravity (maybe even give it a SOI)
Thanks in advance.
Rohnek Kdosi
RKBS Software
Answer by tormentoarmagedoom · May 08, 2018 at 02:39 PM
Good day again.
You need to create a vector that is re-calculated every frame, so in Update, and apply a force to the rigidbody in that direction.
What direction? Easy, you know the vector position of both objects (lets call them earth and moon to make it easier)
Vector3 RelativeDirection = new Vector3 (Moon.transform.position-Earth.transform-position);
But as you only want the direction, is better to have a normalized vector (so magnitude is 1)
Vector3 GravityDirection = RelativeDirection.Normalize();
If helped, accept the answer!
Bye:D
Hi, How exactly do I accomplish such thing? I have no clue about how to find out, which direction to apply the force? Thanks
Accept the answeer to help others easy find it :D
Bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612162247im_/https://answers.unity.com/themes/thub/images/avi.jpg)