- Home /
How would I go About making a flying player move forward, but also Around another object?
So heres what Im trying to make, Picture something like starfox 64, but its not a rail shooter, you can move in completely 360 degrees. The problem that we ran into was there was no way to limit how far the player can move, we tried hardcoding the player/ enemies to teleport to the other sides of the map, sort of like a 3d pacman map, but the teleporting function proved to be sort of pointless since you cant see anything on the other side, and you can get stuck in corners really bad.
So this is what I want to do instead, There will be a planet in the middle of the level. Your player, and everything else, will be constantly orbitting the planet, but you will still be able to move in any direction you want, but we will have limits to how far up and down you can move. I found this tutorial https://www.youtube.com/watch?v=TicipSVT-T8 and tried this, but since my player is flying in outerspace, there is no gravity, so this doesnt really work.
right now the players movement is simply
transform.position = (transform.forward * moveSpeed * 0.01f) + transform.position;
and rotating the player is
if (Input.GetAxis("Horizontal") != 0)
{
yturn += Time.deltaTime * Mathf.Sign(Input.GetAxis("Horizontal"));
yturn = Mathf.Clamp(yturn, -maxTurnSpeed, maxTurnSpeed);
}
else
{
yResetTimer += Time.deltaTime / 80;
yResetTimer = Mathf.Clamp(yResetTimer, 0, 1);
yturn = Mathf.Lerp(yturn, 0, yResetTimer);
}
if (Input.GetAxis("Vertical") != 0)
{
xturn += Time.deltaTime * Mathf.Sign(Input.GetAxis("Vertical"));
xturn = Mathf.Clamp(xturn, -maxTurnSpeed, maxTurnSpeed);
}
else
{
xResetTimer += Time.deltaTime / 80;
xResetTimer = Mathf.Clamp(xResetTimer, 0, 1);
xturn = Mathf.Lerp(xturn, 0, xResetTimer);
}
transform.Rotate(Vector3.up * yturn);
transform.Rotate(Vector3.right * xturn * invert);
I know there has to be a way I can use transform.rotateAround
and our code, and im just overthinking it, but I cant for the life of me figure it out.