// Update is called once per frame void Update() { if (anchorTarget) { float dist = Vector3.Distance(anchorTarget.transform.position, transform.position); if (dist >= pullDist) { InteractionBehaviour targetInteraction = anchorTarget.GetComponent <InteractionBehaviour>(); targetInteraction.OnGraspEnd -= OnGraspEnd; targetInteraction.OnGraspBegin -= OnGraspBegin; // clone stuff, manage attachment GameObject clone = GameObject.Instantiate(anchorTarget, anchorTarget.transform.parent); InteractionBehaviour cloneInteraction = clone.GetComponent <InteractionBehaviour>(); cloneInteraction.OnGraspEnd += OnGraspEnd; cloneInteraction.OnGraspBegin += OnGraspBegin; // enable our anchor anchor.enabled = true; InteractionBehaviour interaction = clone.GetComponent <InteractionBehaviour>(); AnchorableBehaviour anchorable = clone.GetComponent <AnchorableBehaviour>(); //anchorable.transform.SetPositionAndRotation(anchor.transform.position, anchor.transform.rotation); interaction.rigidbody.position = transform.position; interaction.rigidbody.rotation = transform.rotation; anchorable.anchor = anchor; anchorable.TryAttach(true); anchorTarget = clone.gameObject; } } }
void Start() { thisIbehave = GetComponent <InteractionBehaviour>(); thisABehave = GetComponent <AnchorableBehaviour>(); thisABehave.OnDetachedFromAnchor += detach; initPos = gameObject.transform.position; }
void Reset() { if (anchObj == null) { anchObj = GetComponent <AnchorableBehaviour>(); } }
private void Start() { initScale = transform.localScale; thisAbehave = GetComponent <AnchorableBehaviour>(); thisAbehave.OnAttachedToAnchor += attach; thisAbehave.OnDetachedFromAnchor += detach; }
private void onPostObjectGraspEnd(AnchorableBehaviour anchObj) { if (_anchObj.preferredAnchor == null) { // Choose a good position and rotation for workstation mode and begin traveling there. Vector3 targetPosition; // Choose the current position if our velocity is small. if (_intObj.rigidbody.velocity.magnitude < MIN_SPEED_TO_ACTIVATE_TRAVELING) { targetPosition = _intObj.rigidbody.position; } else { targetPosition = determineWorkstationPosition(); } Quaternion targetRotation = determineWorkstationRotation(targetPosition); beginTraveling(_intObj.rigidbody.position, _intObj.rigidbody.velocity, _intObj.rigidbody.rotation, _intObj.rigidbody.angularVelocity, targetPosition, targetRotation); } else { // Ensure the workstation is not active or being deactivated if // we are attaching to an anchor. DeactivateWorkstation(); } }
private void Start() { thisCircle.positionCount = 300; thisCircle.useWorldSpace = true; thisABehave = centerHandle.GetComponent <AnchorableBehaviour>(); thisABehave.OnAttachedToAnchor += attach; thisABehave.OnDetachedFromAnchor += detach; }
// Use this for initialization public void Init(CustomAnchor main) { interaction = GetComponent <InteractionBehaviour>(); anchorable = GetComponent <AnchorableBehaviour>(); MainAnchor = main; cam = FindObjectOfType <Camera>(); GraspEnd(); }
private void Start() { inFinalRotation = false; attached = false; keyRigidbody = GetComponent <Rigidbody>(); interactionBehaviour = GetComponent <InteractionBehaviour>(); anchorableBehaviour = GetComponent <AnchorableBehaviour>(); }
private void refreshRequiredComponents() { _intObj = GetComponent <InteractionBehaviour>(); _anchObj = GetComponent <AnchorableBehaviour>(); _intObj.OnGraspedMovement += onGraspedMovement; _anchObj.OnPostTryAnchorOnGraspEnd += onPostObjectGraspEnd; }
void OnGraspEnd() { // return item to slot! anchor.enabled = true; AnchorableBehaviour anchorable = anchorTarget.GetComponent <AnchorableBehaviour>(); anchorable.anchor = anchor; anchorable.TryAttach(true); }
protected virtual void Awake() { anchorable = GetComponent <AnchorableBehaviour>(); placementInteraction = GetComponent <InteractionBehaviour>(); placementRigidbody = GetComponent <Rigidbody>(); spaceChanger = GetComponent <Editing.SpaceChanger>(); switch (mode) { case ControlMode.Runtime: // look for panel in parent attachedPanel = GetComponentInParent <Panel>(); break; case ControlMode.Design: // if InteractionBehavior doesn't exist, // create it. AnchorableBehavior not necessary? // delete it if it exists? if (placementInteraction == null) { placementInteraction = gameObject.AddComponent <InteractionBehaviour>(); } placementInteraction.allowMultiGrasp = true; placementInteraction.graspedMovementType = InteractionBehaviour.GraspedMovementType.Kinematic; // if we're in design mode or design palette mode, // create our edit sound emitters CreateEditSoundEmitters(); spaceChanger.SpaceChanged += SpaceChanger_SpaceChanged; break; case ControlMode.Design_Palette: // if anchorable and InteractionBehavior don't exist, // create them if (placementInteraction == null) { placementInteraction = gameObject.AddComponent <InteractionBehaviour>(); } if (anchorable == null) { anchorable = gameObject.AddComponent <AnchorableBehaviour>(); } placementInteraction.allowMultiGrasp = true; placementInteraction.graspedMovementType = InteractionBehaviour.GraspedMovementType.Nonkinematic; // if we're in design mode or design palette mode, // create our edit sound emitters CreateEditSoundEmitters(); spaceChanger.SpaceChanged += SpaceChanger_SpaceChanged; break; default: break; } }
private void Start() { thisIbehave = gameObject.GetComponent <InteractionBehaviour>(); thisABehave = gameObject.GetComponent <AnchorableBehaviour>(); initialScale = this.transform.localScale; this.transform.localScale = .25f * initialScale; thisABehave.OnAttachedToAnchor += attach; thisABehave.OnDetachedFromAnchor += detach; }
void OnValidate() { if (intObj == null) { intObj = GetComponent <InteractionBehaviour>(); } if (anchObj == null) { anchObj = GetComponent <AnchorableBehaviour>(); } }
//private bool graspedBefore = false; private void Start() { thisIBehave = GetComponent <InteractionBehaviour>(); thisABehave = GetComponent <AnchorableBehaviour>(); thisIBehave.OnGraspBegin += StartInteraction; initialScale = this.transform.localScale; this.transform.localScale = .25f * initialScale; thisABehave.OnAttachedToAnchor += attach; thisABehave.OnDetachedFromAnchor += detach; }
void Awake() { anchor = GetComponent <AnchorableBehaviour>(); cloneValue = 2; ammoClones = new GameObject[cloneValue + 1]; for (int i = 0; i < ammoClones.Length; i++) { ammoClones[i] = Instantiate(cloneObj, transform.position, Quaternion.identity); ammoClones[i].GetComponent <AmmoClone>().bulletAnchor = bulletAnchor; ammoClones[i].SetActive(false); } }
#pragma warning disable 0649, 0414, 0169 private void Start() { //firstSpawn = true; initPos = gameObject.transform.position; initRot = gameObject.transform.rotation; initLocalPos = gameObject.transform.localPosition; initLocalRot = gameObject.transform.localRotation; initScale = gameObject.transform.localScale; thisInteract = gameObject.GetComponent <InteractionBehaviour>(); aBehave = this.GetComponent <AnchorableBehaviour>(); aBehave.OnAttachedToAnchor += attach; aBehave.OnDetachedFromAnchor += detach; }
private void Start() { if (myPintype == pintype.Star) { gameObject.name = "RSDESPin " + count++; } else { gameObject.name = myPintype + " RSDESPin " + count++; } iBehave = GetComponent <InteractionBehaviour>(); aBehave = GetComponent <AnchorableBehaviour>(); myLR = GetComponent <LineRenderer>(); var haloComponent = pinHead.gameObject.GetComponent("Halo"); var haloEnabledProperty = haloComponent.GetType().GetProperty("enabled"); haloEnabledProperty.SetValue(haloComponent, false, null); //This handles the pin head color changes if (pinHead == null) { Debug.Log("pinHead not set in " + name); gameObject.SetActive(false); } pinHead.material.color = UnityEngine.Random.ColorHSV(0, 1, 0.9f, 1, .9f, 1); defaultColor = pinHead.material.color; aBehave.OnAttachedToAnchor += onAttached; aBehave.OnDetachedFromAnchor += onDetached; //This handles the grasp events for the pin iBehave.OnGraspBegin += beginGrasp; iBehave.OnHoverStay += hoverUpdate; if (myPintype != pintype.Star) { RSDESManager.onEarthTilt += onEarthTilt; } localPanel.SetActive(false); horizonPlaneObj.GetComponent <MeshRenderer>().material.SetColor("_TintColor", defaultColor); tuxPenguin.gameObject.SetActive(myPintype == pintype.southPole); polarBear.gameObject.SetActive(myPintype == pintype.northPole); onPinMove += updateStarMode; onPinMove += RSDESManager.ins.callUpdateStarFieldsGlobal; if (myPintype == pintype.Moon || myPintype == pintype.Sun) { iBehave.ignoreGrasping = true; } }
void Start() { NSides = 3; //set defaults here to auto update text Unit = 1; Prism = false; aBehave = GetComponent <AnchorableBehaviour>(); aBehave.OnAttachedToAnchor += attach; //aBehave.OnDetachedFromAnchor += detach; nSideDown.OnPress += (nSideDownFunc); nSideUp.OnPress += (nSideUpFunc); prismToggle.OnPress += (prismToggleFunc); unitSlider.HorizontalSlideEvent += (unitSliderFunc); }
private void Awake() { anchorableBehaviour = GetComponent <AnchorableBehaviour>(); interactionBehaviour = GetComponent <InteractionBehaviour>(); rigidbody = GetComponent <Rigidbody>(); rigidbody.useGravity = false; rigidbody.isKinematic = true; anchorableBehaviour.interactionBehaviour = interactionBehaviour; anchorableBehaviour.anchorRotation = true; anchorableBehaviour.OnAttachedToAnchor += AttachedToAnchor; anchorableBehaviour.OnDetachedFromAnchor += DettachedFromAnchor; }
internal void Setup(BlockGameBox _box) { box = _box; if (mesh == null) { mesh = GetComponent <Renderer>(); } if (anchorableBehaviour == null) { anchorableBehaviour = GetComponent <AnchorableBehaviour>(); } colorLabel = box.AnchorLabel; mesh.material = box.BoxMat; anchorableBehaviour.anchorGroup = box.GroupLabel; anchorableBehaviour.OnAttachedToAnchor += OnAttached; }
private void Start() { if (!firstLabelMade) { firstLabelMade = true; } thisIBehave = GetComponent <InteractionBehaviour>(); thisABehave = GetComponent <AnchorableBehaviour>(); thisIBehave.OnGraspEnd += graspEnd; labelText = GetComponent <TextMeshPro>(); _thisCount = totalCount++; _label = ((char)(65 + (_thisCount % 25))).ToString(); updateText(); }
#pragma warning restore 0649 void Start() { thisABehave = GetComponent <AnchorableBehaviour>(); thisWS = GetComponent <WorkstationBehaviourExample>(); iBehave = GetComponent <InteractionBehaviour>(); //temporairly disable functionality. //thisABehave.OnDetachedFromAnchor += detach; //thisABehave.OnAttachedToAnchor += attach; iBehave.OnGraspEnd += interactionEnd; left.OnPress += (prevActive); right.OnPress += (nextActive); check.OnPress += (selectMGO); POSSpawner.OnPress += (spawnPOS); deselect.OnPress += (deselectFunc); thisAS = GetComponent <AudioSource>(); }
new void Start() { thisAbehave = GetComponent <AnchorableBehaviour>(); thisAbehave.OnDetachedFromAnchor += detach; thisAbehave.OnAttachedToAnchor += attach; capsule = GetComponent <CapsuleCollider>(); this.GetComponent <LineRenderer>().positionCount = 2; Vector3[] positions = new Vector3[2]; positions[0] = 100f * normalDir.normalized; positions[1] = -100f * normalDir.normalized; //positions[0] = positions[2] - 1000 * (positions[2] - positions[1]); //positions[3] = positions[2] + 1000 * (positions[2] - positions[1]); this.GetComponent <LineRenderer>().SetPositions(positions); //capsule.isTrigger = false; capsule.radius = this.GetComponent <LineRenderer>().startWidth * 2.0f; capsule.height = 100f; capsule.direction = 2; thisIbehave = gameObject.GetComponent <InteractionBehaviour>(); //initLayer = gameObject.layer; shipsWheel_rotate.gameObject.SetActive(false); shipsWheel_revolve.gameObject.SetActive(false); shipsWheel_hoist.gameObject.SetActive(false); gameObject.GetComponent <CapsuleCollider>().enabled = true; //thisIbehave.OnGraspEndEvent += onGraspEnd; }
private void Start() { //Allows for attatchment to the anchor anchorableBehaviour = interactionCube.GetComponent <AnchorableBehaviour>(); }
// Start is called before the first frame update void Start() { manager = GetComponentInParent <BlockGameManager>(); anchorableBehaviour = GetComponent <AnchorableBehaviour>(); mesh = GetComponent <Renderer>(); }
private void Start() { anchorableBehaviour = GetComponent<AnchorableBehaviour>(); }