public override void Grab(Controller123 controller, Rigidbody attach) { GameObject gameobject = Object2.Instantiate(gamePrefab); switch (selectObjectToSpawn) { case Thing.Rock: gameobject.GetComponent <Rock>().Grab(controller, attach); break; case Thing.Tree: gameobject.GetComponent <Treee>().Grab(controller, attach); break; case Thing.House: gameobject.GetComponent <HousingMaster>().Grab(controller, attach); break; case Thing.ConstructionFrame: gameobject.GetComponent <ConstructionFrame>().Grab(controller, attach); break; default: break; } }
public override void Grab(Controller123 controller, Rigidbody attach) { //base.Grab(attach); GameObject gameobject = Instantiate(rockPrefab); gameobject.GetComponent <Rock>().Grab(controller, attach); }
private void Throw(Controller123 stuff, SteamVR_Behaviour_Pose pose) { if (stuff.State == ControllerState.Holding) { ServiceLocator.TestAudioMasterService.PlayOneShot(AudioType.SFXThrow, pose.GetComponent <AudioSource>()); stuff.Obj.Throw(pose); } }
private void PickUp(Controller123 stuff, Rigidbody rb, Controller123 other) { if (stuff.State != ControllerState.Empty) { return; } Collider[] hits = new Collider[godConfig.MaxHitsPickUpSphere]; int count = Physics.OverlapSphereNonAlloc(rb.position, godData.RayCastSphereRadius, hits, godConfig.LayerMaskPickUp); if (count < 1) { return; } int nearest = 0; for (int i = 1; i < count; i++) { if (Vector3.Distance(rb.position, hits[nearest].transform.position) < Vector3.Distance(rb.position, hits[i].transform.position)) { continue; } if (other.Obj) { if (hits[nearest].transform == other.Obj.transform) { continue; } } nearest = i; } if (nearest == 0) { if (other.Obj) { if (hits[nearest].transform == other.Obj.transform) { return; } } } InteractableWorldObject obj = hits[nearest].transform.GetComponent <InteractableWorldObject>(); if (!obj) { UnityEngine.Debug.LogWarning("INTERACTABLEWORLDOBJECT PLS"); return; } obj.Grab(stuff, rb); }
public virtual void Drop() { Object.Destroy(joint); joint = null; //Makes sure the controller we held is set correctly heldBy.Obj = null; heldBy.State = ControllerState.Empty; heldBy = null; }
private bool Place(Controller123 stuff, Vector3 position) { RaycastHit[] hits = new RaycastHit[godConfig.MaxHitRay]; if (Physics.RaycastNonAlloc(position, Vector3.down, hits, godData.RayPlaceDistance, godConfig.LayerMaskTerrain) < 1) { //UnityEngine.Debug.Log("Failed to Place"); return(false); } //Keep hand rotation var rotation = stuff.Obj.transform.eulerAngles = (new Vector3(0.0f, stuff.Obj.transform.eulerAngles.y, 0.0f)); return(stuff.Obj.Place(hits[0].point, Quaternion.Euler(rotation))); }
public override void Grab(Controller123 controller, Rigidbody attach) { if (isGrabbable) { Regrow(); pineParticles.Play(); //base.Grab(attach); GameObject gameobject = Object2.Instantiate(treePrefab); gameobject.GetComponent <Treee>().Grab(controller, attach); } else { //Debug.Log("Tree is not ready yet"); } }
public virtual void Grab(Controller123 controller, Rigidbody attach) { rigi.isKinematic = false; if (controller.State == ControllerState.Holding) { return; } if (joint) { return; } joint = gameObject.AddComponent <FixedJoint>(); transform.position = attach.position; joint.connectedBody = attach; heldBy = controller; controller.Obj = this; controller.State = ControllerState.Holding; ServiceLocator.TestAudioMasterService.PlayOneShot(AudioType.SFXGrab, audioSource); }
public override void Grab(Controller123 controller, Rigidbody attach) { base.Grab(controller, attach); rigi.isKinematic = false; }
public override void Grab(Controller123 controller, Rigidbody attach) { //Untouchable house }
public override void Grab(Controller123 controller, Rigidbody attach) { base.Grab(controller, attach); transform.tag = "Untagged"; }