mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: Examples colliders and missing namespace. (#3881)
* fix: Example scene and prefab colliders fixed. No idea what happened, but some box colliders seem to be double the default size. * Namespace to couch coop scripts.
This commit is contained in:
parent
b409245946
commit
5b7da43d5c
@ -165,7 +165,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &34377706
|
--- !u!23 &34377706
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -258,7 +258,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &80415369
|
--- !u!23 &80415369
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -497,7 +497,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &121552836
|
--- !u!23 &121552836
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -642,7 +642,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &388677688
|
--- !u!23 &388677688
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -792,7 +792,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &446496355
|
--- !u!23 &446496355
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -928,7 +928,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &498523325
|
--- !u!23 &498523325
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1183,7 +1183,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &738449928
|
--- !u!23 &738449928
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1319,7 +1319,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &828682888
|
--- !u!23 &828682888
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1412,7 +1412,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &898358223
|
--- !u!23 &898358223
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1697,7 +1697,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1179387014
|
--- !u!23 &1179387014
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1829,7 +1829,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1218169083
|
--- !u!23 &1218169083
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -1922,7 +1922,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1263590062
|
--- !u!23 &1263590062
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -2091,7 +2091,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1284513254
|
--- !u!23 &1284513254
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -2565,7 +2565,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &1648326111
|
--- !u!23 &1648326111
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
@ -3174,7 +3174,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!23 &2105958124
|
--- !u!23 &2105958124
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
|
@ -1,76 +1,79 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Mirror;
|
using Mirror;
|
||||||
|
|
||||||
public class MovingPlatform : NetworkBehaviour
|
namespace Mirror.Examples.CouchCoop
|
||||||
{
|
{
|
||||||
public Transform endTarget;
|
public class MovingPlatform : NetworkBehaviour
|
||||||
public float moveSpeed = 0.5f;
|
|
||||||
// allows for on demand syncing of stopping and starting platform movement, change via server
|
|
||||||
// note,sync vars changed via inspector do not sync. This is optional feature, can be removed
|
|
||||||
[SyncVar]
|
|
||||||
public bool moveObj = true;
|
|
||||||
|
|
||||||
// optional fancy features
|
|
||||||
public bool moveStopsUponExit = false;
|
|
||||||
public bool moveStartsUponCollision = false;
|
|
||||||
|
|
||||||
private Vector3 startPosition;
|
|
||||||
private Vector3 endPosition;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
{
|
||||||
startPosition = transform.position;
|
public Transform endTarget;
|
||||||
endPosition = endTarget.position;
|
public float moveSpeed = 0.5f;
|
||||||
}
|
// allows for on demand syncing of stopping and starting platform movement, change via server
|
||||||
|
// note,sync vars changed via inspector do not sync. This is optional feature, can be removed
|
||||||
|
[SyncVar]
|
||||||
|
public bool moveObj = true;
|
||||||
|
|
||||||
void Update()
|
// optional fancy features
|
||||||
{
|
public bool moveStopsUponExit = false;
|
||||||
if (moveObj)
|
public bool moveStartsUponCollision = false;
|
||||||
|
|
||||||
|
private Vector3 startPosition;
|
||||||
|
private Vector3 endPosition;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
{
|
{
|
||||||
float step = moveSpeed * Time.deltaTime;
|
startPosition = transform.position;
|
||||||
transform.position = Vector3.MoveTowards(transform.position, endPosition, step);
|
endPosition = endTarget.position;
|
||||||
|
}
|
||||||
|
|
||||||
if (Vector3.Distance(transform.position, endPosition) < 0.001f)
|
void Update()
|
||||||
|
{
|
||||||
|
if (moveObj)
|
||||||
{
|
{
|
||||||
endPosition = endPosition == startPosition ? endTarget.position : startPosition;
|
float step = moveSpeed * Time.deltaTime;
|
||||||
if (isServer)
|
transform.position = Vector3.MoveTowards(transform.position, endPosition, step);
|
||||||
|
|
||||||
|
if (Vector3.Distance(transform.position, endPosition) < 0.001f)
|
||||||
{
|
{
|
||||||
RpcResyncPosition(endPosition == startPosition ? (byte)1 : (byte)0);
|
endPosition = endPosition == startPosition ? endTarget.position : startPosition;
|
||||||
|
if (isServer)
|
||||||
|
{
|
||||||
|
RpcResyncPosition(endPosition == startPosition ? (byte)1 : (byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ClientRpc]
|
||||||
|
void RpcResyncPosition(byte _value)
|
||||||
|
{
|
||||||
|
//print("RpcResyncPosition: " + _value);
|
||||||
|
transform.position = _value == 1 ? endTarget.position : startPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional
|
||||||
|
[ServerCallback]
|
||||||
|
private void OnCollisionEnter(Collision collision)
|
||||||
|
{
|
||||||
|
if (moveStartsUponCollision)
|
||||||
|
{
|
||||||
|
if (collision.gameObject.tag == "Player")
|
||||||
|
{
|
||||||
|
moveObj = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional
|
||||||
|
[ServerCallback]
|
||||||
|
private void OnCollisionExit(Collision collision)
|
||||||
|
{
|
||||||
|
if (moveStopsUponExit)
|
||||||
|
{
|
||||||
|
if (collision.gameObject.tag == "Player")
|
||||||
|
{
|
||||||
|
moveObj = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ClientRpc]
|
|
||||||
void RpcResyncPosition(byte _value)
|
|
||||||
{
|
|
||||||
//print("RpcResyncPosition: " + _value);
|
|
||||||
transform.position = _value == 1 ? endTarget.position : startPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional
|
|
||||||
[ServerCallback]
|
|
||||||
private void OnCollisionEnter(Collision collision)
|
|
||||||
{
|
|
||||||
if (moveStartsUponCollision)
|
|
||||||
{
|
|
||||||
if (collision.gameObject.tag == "Player")
|
|
||||||
{
|
|
||||||
moveObj = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional
|
|
||||||
[ServerCallback]
|
|
||||||
private void OnCollisionExit(Collision collision)
|
|
||||||
{
|
|
||||||
if (moveStopsUponExit)
|
|
||||||
{
|
|
||||||
if (collision.gameObject.tag == "Player")
|
|
||||||
{
|
|
||||||
moveObj = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,46 +1,49 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Mirror;
|
using Mirror;
|
||||||
|
|
||||||
public class PlatformMovement : NetworkBehaviour
|
namespace Mirror.Examples.CouchCoop
|
||||||
{
|
{
|
||||||
// A separate script to handle platform behaviour, see its partner script, MovingPlatform.cs
|
public class PlatformMovement : NetworkBehaviour
|
||||||
private bool onPlatform;
|
|
||||||
private Transform platformTransform;
|
|
||||||
private Vector3 lastPlatformPosition;
|
|
||||||
|
|
||||||
public override void OnStartAuthority()
|
|
||||||
{
|
{
|
||||||
this.enabled = true;
|
// A separate script to handle platform behaviour, see its partner script, MovingPlatform.cs
|
||||||
}
|
private bool onPlatform;
|
||||||
|
private Transform platformTransform;
|
||||||
|
private Vector3 lastPlatformPosition;
|
||||||
|
|
||||||
void FixedUpdate()
|
public override void OnStartAuthority()
|
||||||
{
|
|
||||||
if (onPlatform)
|
|
||||||
{
|
{
|
||||||
Vector3 deltaPosition = platformTransform.position - lastPlatformPosition;
|
this.enabled = true;
|
||||||
transform.position += deltaPosition;
|
|
||||||
lastPlatformPosition = platformTransform.position;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCollisionEnter(Collision collision)
|
void FixedUpdate()
|
||||||
{
|
|
||||||
|
|
||||||
if (collision.gameObject.tag == "Finish")
|
|
||||||
{
|
{
|
||||||
platformTransform = collision.gameObject.GetComponent<Transform>();
|
if (onPlatform)
|
||||||
lastPlatformPosition = platformTransform.position;
|
{
|
||||||
onPlatform = true;
|
Vector3 deltaPosition = platformTransform.position - lastPlatformPosition;
|
||||||
|
transform.position += deltaPosition;
|
||||||
|
lastPlatformPosition = platformTransform.position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCollisionExit(Collision collision)
|
private void OnCollisionEnter(Collision collision)
|
||||||
{
|
|
||||||
// ideally set a Platform tag, but we'l just use a Unity Pre-set.
|
|
||||||
if (collision.gameObject.tag == "Finish")
|
|
||||||
{
|
{
|
||||||
onPlatform = false;
|
|
||||||
platformTransform = null;
|
if (collision.gameObject.tag == "Finish")
|
||||||
|
{
|
||||||
|
platformTransform = collision.gameObject.GetComponent<Transform>();
|
||||||
|
lastPlatformPosition = platformTransform.position;
|
||||||
|
onPlatform = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCollisionExit(Collision collision)
|
||||||
|
{
|
||||||
|
// ideally set a Platform tag, but we'l just use a Unity Pre-set.
|
||||||
|
if (collision.gameObject.tag == "Finish")
|
||||||
|
{
|
||||||
|
onPlatform = false;
|
||||||
|
platformTransform = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ BoxCollider:
|
|||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 2, y: 2, z: 2}
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
m_Center: {x: 0, y: 0.5, z: -0.1}
|
m_Center: {x: 0, y: 0.5, z: -0.1}
|
||||||
--- !u!114 &4118329204170882586
|
--- !u!114 &4118329204170882586
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
Loading…
Reference in New Issue
Block a user