I am trying to create a simple game using Amazon Lumberyard and my goal is to have levels/stages where the player will be able to walk around a mini planet.
I have seen a lot of tutorials about this for Unity, but I find it hard to try to translate this into Lua.
My problem is trying to make the "Feet" of the character point towards the planet. Any help would be appreciated.
the script I got for unity is below,
Planet
public class PlanetScript : MonoBehaviour {
public float gravity = -12;
public void Attract(Transform playerTransform)
{
Vector3 gravityUp = (playerTransform.position - transform.position).normalized;
Vector3 localUp = playerTransform.up;
playerTransform.GetComponent<Rigidbody>().AddForce(gravityUp * gravity);
Quaternion targetRotation = Quaternion.FromToRotation(localUp, gravityUp) * playerTransform.rotation;
playerTransform.rotation = Quaternion.Slerp(playerTransform.rotation, targetRotation, 50f * Time.deltaTime);
}
}
and the player has
void FixedUpdate()
{
if (attractorPlanet)
{
attractorPlanet.Attract(playerTransform);
}
}