Just fixed the problem by the following script:
Code:
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Rigidbody))]
public class GravityBody : MonoBehaviour {
GravityAttractor planet;
void Awake()
{
planet = GameObject.FindGameObjectWithTag("Planet").GetComponent<GravityAttractor>();
GetComponent<Rigidbody>().useGravity = false;
GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
}
void FixedUpdate ()
{
planet.Attract(transform);
}
}
My questions for now are, which collider is the right one for an static object like a tree. You should not be able to walk through a tree, but a box collider or capsule collider is not the right one because of placing a bareer over it.
My next question is, the tree is rotated on his backside and then pulled on the sphere, you can watch this on the picture