mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fully fix spawns
This commit is contained in:
parent
6c3c47b011
commit
e3fff97ba0
@ -41,22 +41,18 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
InvulnerabilityHandler.MakeInvulnerable(true);
|
||||
|
||||
var player = SearchUtilities.Find("Player_Body").GetAttachedOWRigidbody();
|
||||
var spawn = GetDefaultSpawn();
|
||||
|
||||
// Idk why but these just don't work?
|
||||
var matchInitialMotion = player.GetComponent<MatchInitialMotion>();
|
||||
var matchInitialMotion = SearchUtilities.Find("Player_Body").GetComponent<MatchInitialMotion>();
|
||||
if (matchInitialMotion != null) UnityEngine.Object.Destroy(matchInitialMotion);
|
||||
|
||||
Main.Instance.StartCoroutine(SpawnCoroutine(player, spawn, 5));
|
||||
Main.Instance.StartCoroutine(SpawnCoroutine(2));
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerator SpawnCoroutine(OWRigidbody playerBody, SpawnPoint spawn, int length)
|
||||
private static IEnumerator SpawnCoroutine(int length)
|
||||
{
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
playerBody.WarpToPositionRotation(spawn.transform.position, spawn.transform.rotation);
|
||||
FixVelocity();
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
@ -66,16 +62,12 @@ namespace NewHorizons.Handlers
|
||||
|
||||
private static void FixVelocity()
|
||||
{
|
||||
var player = SearchUtilities.Find("Player_Body");
|
||||
var playerBody = player.GetAttachedOWRigidbody();
|
||||
var playerBody = SearchUtilities.Find("Player_Body").GetAttachedOWRigidbody();
|
||||
var spawn = GetDefaultSpawn();
|
||||
var resources = playerBody.GetComponent<PlayerResources>();
|
||||
|
||||
playerBody.WarpToPositionRotation(spawn.transform.position, spawn.transform.rotation);
|
||||
|
||||
// Player dies during the teleport sometimes so we prevent that
|
||||
var resources = player.GetComponent<PlayerResources>();
|
||||
var deathManager = Locator.GetDeathManager();
|
||||
|
||||
var spawnVelocity = spawn._attachedBody.GetVelocity();
|
||||
var spawnAngularVelocity = spawn._attachedBody.GetPointTangentialVelocity(playerBody.transform.position);
|
||||
var velocity = spawnVelocity + spawnAngularVelocity;
|
||||
@ -84,10 +76,6 @@ namespace NewHorizons.Handlers
|
||||
NHLogger.LogVerbose($"Player spawn velocity {velocity} Player velocity {playerBody.GetVelocity()} spawn body {spawnVelocity} spawn angular vel {spawnAngularVelocity}");
|
||||
|
||||
resources._currentHealth = 100f;
|
||||
|
||||
resources._invincible = _wasInvincible;
|
||||
deathManager._invincible = _wasDeathManagerInvincible;
|
||||
deathManager._impactDeathSpeed = _impactDeathSpeed;
|
||||
}
|
||||
|
||||
private static Vector3 CalculateMatchVelocity(OWRigidbody owRigidbody, OWRigidbody bodyToMatch, bool ignoreAngularVelocity)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user