Implement respawn position

This commit is contained in:
Denis-Cosmin Nutiu 2019-06-01 21:04:37 +03:00
parent a585a649d2
commit 658bbc7b5d
3 changed files with 44 additions and 4 deletions

View file

@ -18,7 +18,6 @@
<Path>.idea</Path> <Path>.idea</Path>
<Path>Library</Path> <Path>Library</Path>
<Path>Logs</Path> <Path>Logs</Path>
<Path>Temp</Path>
<Path>obj</Path> <Path>obj</Path>
</explicitExcludes> </explicitExcludes>
</component> </component>

View file

@ -7628,6 +7628,36 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3} m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!1 &185746014
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 185746015}
m_Layer: 0
m_Name: RespawnPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &185746015
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 185746014}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -7.564, y: 2.318, z: -9.895229}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &266944714 --- !u!1 &266944714
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7691,7 +7721,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 266944714} m_GameObject: {fileID: 266944714}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -6.47, y: 1.52, z: -2.7893844} m_LocalPosition: {x: -10.33, y: 1.49, z: -2.7893844}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 97386695} - {fileID: 97386695}
@ -7829,7 +7859,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028} m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.6028743, y: -2.0120425, z: -2.7893844} m_LocalPosition: {x: 1.6028738, y: -2.0120423, z: -2.7893844}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -7976,6 +8006,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
movementSpeed: 4 movementSpeed: 4
respawnPosition: {fileID: 185746015}
--- !u!212 &1352658976 --- !u!212 &1352658976
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -8032,7 +8063,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974} m_GameObject: {fileID: 1352658974}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -6.47, y: 1.52, z: 7.2106156} m_LocalPosition: {x: -10.33, y: 1.49, z: 7.2106156}
m_LocalScale: {x: 7, y: 7, z: 0} m_LocalScale: {x: 7, y: 7, z: 0}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View file

@ -6,9 +6,14 @@ namespace src.Player
{ {
public class PlayerController : PlayerBase public class PlayerController : PlayerBase
{ {
public Transform respawnPosition;
protected new void Start() protected new void Start()
{ {
base.Start(); base.Start();
/* Always start at the starting point. */
Respawn();
} }
private void Update() private void Update()
@ -41,5 +46,10 @@ namespace src.Player
// Console movement is not supported yet. // Console movement is not supported yet.
#endif #endif
} }
private void Respawn()
{
transform.position = respawnPosition.position;
}
} }
} }