public void PullReset(NetworkInstanceId netID) { PullObjectID = netID; transform.hasChanged = false; if (netID == NetworkInstanceId.Invalid) { if (PullingObject != null) { pullRegister.UpdatePosition(); //Could be another player PlayerSync otherPlayerSync = PullingObject.GetComponent <PlayerSync>(); if (otherPlayerSync != null) { CmdSetPositionFromReset(gameObject, otherPlayerSync.gameObject, PullingObject.transform.position); } } pullRegister = null; PullingObject = null; } else { PullingObject = ClientScene.FindLocalObject(netID); PushPull oA = PullingObject.GetComponent <PushPull>(); pullPos = PullingObject.transform.localPosition; if (oA != null) { oA.pulledBy = gameObject; } pullRegister = PullingObject.GetComponent <RegisterTile>(); } }
private void PullObject() { pullPos = transform.localPosition - (Vector3)LastDirection; pullPos.z = PullingObject.transform.localPosition.z; Vector3Int pos = Vector3Int.RoundToInt(pullPos); if (matrix.IsPassableAt(pos) || matrix.ContainsAt(pos, gameObject) || matrix.ContainsAt(pos, PullingObject)) { float journeyLength = Vector3.Distance(PullingObject.transform.localPosition, pullPos); if (journeyLength <= 2f) { PullingObject.transform.localPosition = Vector3.MoveTowards(PullingObject.transform.localPosition, pullPos, playerMove.speed * Time.deltaTime / journeyLength); } else { //If object gets too far away activate warp speed PullingObject.transform.localPosition = Vector3.MoveTowards(PullingObject.transform.localPosition, pullPos, playerMove.speed * Time.deltaTime * 30f); } PullingObject.BroadcastMessage("FaceDirection", playerSprites.currentDirection, SendMessageOptions.DontRequireReceiver); } }
private void PullObject() { Vector3 proposedPos = Vector3.zero; if (isLocalPlayer) { proposedPos = transform.localPosition - (Vector3)LastDirection; } else { proposedPos = transform.localPosition - (Vector3)serverLastDirection; } Vector3Int pos = Vector3Int.RoundToInt(proposedPos); if (matrix.IsPassableAt(pos) || matrix.ContainsAt(pos, gameObject) || matrix.ContainsAt(pos, PullingObject)) { //if (isLocalPlayer) //{ pullJourney = Vector3.Distance(PullingObject.transform.localPosition, transform.localPosition) - offsetTest; if (pullJourney < 1.2f) { pullJourney = 1f; } if (pullJourney > 1.5f) { pullJourney *= 1.2f; } //} else //{ // pullJourney = Vector3.Distance(PullingObject.transform.localPosition, transform.localPosition); //} pullPos = proposedPos; pullPos.z = PullingObject.transform.localPosition.z; PullingObject.BroadcastMessage("FaceDirection", playerSprites.currentDirection, SendMessageOptions.DontRequireReceiver); } }