/// <summary> /// The IsObjectManipulable method is used to check if a given game object is of type `ManipulableObject` and whether the object is enabled. /// </summary> /// <param name="obj">The game object to check to see if it's manipulable.</param> /// <returns>Is true if the given object is of type `ManipulableObject`.</returns> public virtual bool IsObjectManipulable(GameObject obj) { if (obj != null) { ManipulableObject io = obj.GetComponentInParent <ManipulableObject>(); if (io != null) { return(io.enabled); } } return(false); }
private void DetectTarget() { RaycastHit hit; Ray ray = getCameraRay(); if (Physics.Raycast(ray, out hit) && maxDistance >= hit.distance && hit.collider.gameObject.CompareTag("Manipulable")) { target = hit.collider.gameObject; targetComponent = target.GetComponent <ManipulableObject>(); inSight = true; } else { target = null; inSight = false; } }
public virtual GameObject InstantiateLibraryObject(LibraryObject libObj, Vector3 worldPos) { //Debug.Log("inst, "); GameObject go = libObj.Instantiate(worldPos); //Debug.Log("inst "+go.name); go.transform.SetParent(transform, true); ManipulableObject man = go.GetComponent <ManipulableObject>(); if (man == null && addManipulableBehaviorToInstances) { go.AddComponent <ManipulableObject>(); man = go.GetComponent <ManipulableObject>(); man.boxCollider = go.GetComponent <BoxCollider>(); man.VERTICAL_MOVEMENT_ENABLED = false; man.START_ENABLED = true; } Animator anim = go.GetComponentInChildren <Animator>(); if (anim != null) { Debug.Log("Object has an Animator"); } if (man != null) { man.worldObjects = this; } AddInstantiatedObject(go); SelectedObject = go; // Select it onInstantiatedObject.Invoke(go); return(go); }