#Planetary Gravity Question
1 messages · Page 1 of 1 (latest)
just thought that maybe this was a common issue with making gravity like this, ill add some code snipps
It depends on what your gravity is. are you using the defaul tgravity? That wont work because its always down on y axis.
this is my planetaryGravity code:
{
public static List<PlanetaryGravity> AllPlanets = new List<PlanetaryGravity>();
[SerializeField] private float gravity = 9.8f;
public float Gravity => gravity;
void Awake()
{
if (!AllPlanets.Contains(this))
AllPlanets.Add(this);
}
void OnDestroy()
{
AllPlanets.Remove(this);
}
public Vector3 GetGravityDirection(Vector3 position)
{
return (transform.position - position).normalized;
}
}```
and then the txt file is for every object affected by the gravity, i use a player controller package which is linked to the invector reference, and ive followed multiple tutorials for the gravity
!code please, not just a huge text file
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
And I dont know what player controller package is.
you dont really need the player controller, just that the invector reference references the player controller.
A tool for sharing your source code with the world!
Just from seeing the video, I assume, your character is not pointing towards the center of mass of the planet, right? And without a first prototype of just achieving this, adding more packages wont help you debug it.
i had this working with a capsule, and eventually a tposing model in a different project, migrated it into a new one, and added animations to get this result
So the animations might be the issue? Are they overwriting the rotation of your gameobject?
Animations can do that. Got to be careful when adding animations to custom physics.