a 2d planet in the center, where the players will be able to walk on it and also will be affected by center gravity. planet will be static and there won't be any other planets. so;
Is there a way that I can change the gravity position? yes you can adjust gravity via project settings but I want it to be in the middle x,y,z(0,0,0)
I have tried creating my own gravity but it wasn't very useful because objects wouldnt fall, stand on foot and also in contact with another object they would vibrate instead of standing still. (if they stand on the planet they would vibrate)
private void FixedUpdate()
{
foreach(GameObject item in grav)
{
Attact(item);
}
}
private void Attact(GameObject gmf)
{
Rigidbody2D rgg = gmf.GetComponent<Rigidbody2D>();
Vector3 direction = rg2d.position - rgg.position;
float distance = direction.sqrMagnitude;
float forceMag = (10 * rgg.mass) / distance;
Vector3 force = direction.normalized * forceMag * 10;
rgg.AddForce(force);
}
I can create a script that will change the gravity by the opposite of the object's position. this does work but I cannot see any way to do it for more than one object.