void PickUp(GameObject newWeapon) { if (!Arachnid.Math.LayerMaskContainsLayer(layersCanPickUp, newWeapon.layer)) { return; } FlingSword newWeaponSword = newWeapon.GetComponent <FlingSword>(); if (!newWeaponSword) { Debug.LogError(name + " tried to pickup weapon but it has no fling sword component.", newWeapon); return; } Hauntable hauntable = newWeaponSword.GetComponent <Hauntable>(); if (hauntable) { hauntable.EndHaunt(); } wieldedObject = newWeaponSword; wieldedObject.gameObject.SetActive(false); wieldedObject.transform.parent = transform; wieldedObject.transform.localPosition = wieldedObjectOffset; wieldedObjectFSM = wieldedObject.GetComponent <PlayMakerFSM>(); onWeaponPickedUp.Invoke(); Debug.Log("Picked up " + newWeapon.name); }
public void FlingMyObject() { if (preventCollisionWithSelf) { var flingCollider = wieldedObject.GetComponent <Collider>(); if (flingCollider != null) { flingCollider.enabled = false; StartCoroutine(EnableCollider(flingCollider, .3f)); } } // Disable the flingSword behavior so it doesn't get fling direction from its own rubber band wieldedObject.enabled = false; wieldedObject.gameObject.SetActive(true); wieldedObject.transform.parent = null; wieldedObject.flingDirection = ghostOnMe ? ghostOnMe.forceVector : Vector3.right; wieldedObjectFSM.SendEvent("fling"); wieldedObject = null; }