public void DropObject() { Debug.Log("Host: Drop"); if (holding != null) { holdingPeck.Released(); holding.SetParent(null); holding = null; holdingPeck = null; } curTarget = null; }
public void OnChirp(InputAction.CallbackContext ctx) { if (ctx.performed) { curTarget = null; if (routine != null) { StopCoroutine(routine); } routine = StartCoroutine(AbilityRoutine(ChirpPos, 5, 0.1f, 3.5f, 0.05f, 1, true)); } }
private void Pickup() { if (curTarget != null) { holding = curTarget.Pecked(); holdingPeck = curTarget.GetThis(); if (holding != null) { holding.SetParent(transform); holding.localPosition = new Vector3(0, 0, 0.85f); } curTarget = null; } }
private void FindPeckTarget() { Collider[] colliders = Physics.OverlapSphere(transform.position + transform.forward / 2 - Vector3.up / 4, 1); foreach (Collider other in colliders) { curTarget = other.GetComponent <IPeckable>(); if (curTarget != null) { // Other Pos PeckPos.position = other.transform.position; PeckPos.rotation = Quaternion.LookRotation(other.transform.position - transform.position); return; } } curTarget = null; // Default Pos PeckPos.position = transform.parent.position + transform.parent.forward * 0.8f; PeckPos.rotation = transform.parent.rotation; }
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { if (holdingPeck != null && PecksList._instance.peckables.ContainsKey(holdingPeck.ID())) { stream.SendNext(holdingPeck.ID()); } else { stream.SendNext(99999); } stream.SendNext(SendChirp); SendChirp = false; } else { int index = (int)stream.ReceiveNext(); bool alreadyHolding = false; // If holding something if (index != 99999) { IPeckable pecked = PecksList._instance.peckables[index]; if (holdingPeck == pecked) { alreadyHolding = true; // If already holding it } else { holdingPeck = pecked; // else } } // If not holding anything else { // If you are holding then drop it if (holding != null) { holdingPeck.Released(); holding.SetParent(null); holdingPeck = null; holding = null; } } // If you started holding something, run pickup code if (holdingPeck != null && alreadyHolding == false) { holding = holdingPeck.Pecked(); holding.SetParent(transform); holding.localPosition = new Vector3(0, 0, 0.85f); } if ((bool)stream.ReceiveNext()) { Chirp(); } } }