Player.cs with camera mount

This commit is contained in:
mischa 2023-12-13 11:30:56 +01:00
parent a971007e02
commit f39f669d5e
4 changed files with 53 additions and 0 deletions

View File

@ -45,6 +45,7 @@ GameObject:
- component: {fileID: 5494952544308740966}
- component: {fileID: 5494952544308740984}
- component: {fileID: 5494952544308740987}
- component: {fileID: -6612530066273007424}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
@ -170,3 +171,19 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 1
--- !u!114 &-6612530066273007424
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5494952544308740986}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ca56588750e2488d972de17a0f71f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 0
syncMode: 0
syncInterval: 0
cameraMount: {fileID: 5741080586963324589}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2ceee57e91e1142738e0d041d618f7ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
using UnityEngine;
namespace Mirror.Examples.Shooter
{
public class Player : NetworkBehaviour
{
public Transform cameraMount;
public override void OnStartLocalPlayer()
{
// move main camera into camera mount
Camera.main.transform.SetParent(cameraMount, false);
Camera.main.transform.localPosition = Vector3.zero;
Camera.main.transform.localRotation = Quaternion.identity;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ca56588750e2488d972de17a0f71f5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: