Fix PlayerSpawnController bug that sometimes caused player to spawn in wrong location
This commit is contained in:
@@ -312,7 +312,7 @@ MeshRenderer:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 455432347}
|
m_GameObject: {fileID: 455432347}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_CastShadows: 1
|
m_CastShadows: 1
|
||||||
m_ReceiveShadows: 1
|
m_ReceiveShadows: 1
|
||||||
m_DynamicOccludee: 1
|
m_DynamicOccludee: 1
|
||||||
@@ -1383,7 +1383,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7190262219221540737, guid: b273c0298305ae84e9a55d1de630edc0, type: 3}
|
- target: {fileID: 7190262219221540737, guid: b273c0298305ae84e9a55d1de630edc0, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: 24.68
|
value: 23
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7190262219221540737, guid: b273c0298305ae84e9a55d1de630edc0, type: 3}
|
- target: {fileID: 7190262219221540737, guid: b273c0298305ae84e9a55d1de630edc0, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PlayerSpawnController : MonoBehaviour
|
public class PlayerSpawnController : MonoBehaviour
|
||||||
@@ -9,7 +10,17 @@ public class PlayerSpawnController : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject _spawnLocation;
|
private GameObject _spawnLocation;
|
||||||
|
|
||||||
void Awake()
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
var otherSpawnControllers = FindObjectsOfType<PlayerSpawnController>().Except(new[] { this });
|
||||||
|
if (otherSpawnControllers.Any())
|
||||||
|
Destroy(this);
|
||||||
|
else
|
||||||
|
DontDestroyOnLoad(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
{
|
{
|
||||||
if (GameObject.FindGameObjectWithTag("Player") != null)
|
if (GameObject.FindGameObjectWithTag("Player") != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 7190262219221540742}
|
m_GameObject: {fileID: 7190262219221540742}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 26.18, y: 24.68, z: -18.753551}
|
m_LocalPosition: {x: 26.18, y: 23, z: -18.753551}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
|
|||||||
Reference in New Issue
Block a user