Started server-sided rope

This commit is contained in:
BOTAlex 2024-02-28 18:59:39 +01:00
parent 4b228771e5
commit f203b6d710
3 changed files with 27 additions and 8 deletions

View File

@ -3669,7 +3669,10 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 3032075919872812610, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
insertIndex: -1
addedObject: {fileID: 4910321061857220296}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 809911508645467208, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
insertIndex: -1
@ -3678,6 +3681,11 @@ PrefabInstance:
insertIndex: -1
addedObject: {fileID: 1683288374126251330}
m_SourcePrefab: {fileID: 100100000, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
--- !u!4 &1683288374126251322 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3032075919872812610, guid: ec5007446d8bbca48bf02b3a7e752da1, type: 3}
m_PrefabInstance: {fileID: 1683288374126251321}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1683288374126251323
MonoBehaviour:
m_ObjectHideFlags: 0
@ -3834,7 +3842,7 @@ PrefabInstance:
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 1683288374126251322}
m_Modifications:
- target: {fileID: 144529238244638330, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
propertyPath: m_LocalPosition.x
@ -3885,6 +3893,11 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
--- !u!4 &4910321061857220296 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 144529238244638330, guid: 0248db69242a3dd47898c6742b6c9f60, type: 3}
m_PrefabInstance: {fileID: 4910321061857220295}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &5796191506433166633
PrefabInstance:
m_ObjectHideFlags: 0
@ -4763,7 +4776,6 @@ PrefabInstance:
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 4910321061857220295}
- {fileID: 1683288374126251321}
- {fileID: 1536317696}
- {fileID: 4158834148864819266}

View File

@ -6,7 +6,9 @@
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:ddd4dba7c768b564a879069c52854fc5",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb"
"GUID:c0e1b40f519e6e84b8f4af9930403ecb",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b",
"GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -2,10 +2,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Assertions;
public class RopeSimulator : MonoBehaviour
public class RopeSimulator : NetworkBehaviour
{
[SerializeField]
private float gravity = 10;
@ -246,7 +247,7 @@ public class RopeSimulator : MonoBehaviour
// Benjamin forgor... to assign
if (ropeCollidersParent == null)
{
var holder = new GameObject("RopeHolder");
var holder = new GameObject("RopeColiderHolder");
ropeCollidersParent = holder.transform;
}
@ -263,8 +264,12 @@ public class RopeSimulator : MonoBehaviour
ropeCollider.transform.position = point.position;
ropeCollider.layer = LayerMask.NameToLayer("Rope");
var colliderComponent = ropeCollider.AddComponent<CircleCollider2D>();
colliderComponent.radius = ropeRadius;
if (!IsClient) // Only coliders for the server/host
{
var colliderComponent = ropeCollider.AddComponent<CircleCollider2D>();
colliderComponent.radius = ropeRadius;
}
var rigidBody = ropeCollider.AddComponent<Rigidbody2D>();
rigidBody.isKinematic = true;