// Update is called once per frame void Update() { int alive = 0; if (hitSensor.isColliding == true) { alive = hitPoints - hitSensor.targets.Count; } if (alive < 0) { rb3d.gameObject.SetActive(false); } attachedObject = this.GetComponentInChildren <ObjectAttached>(); if (attachedObject != null) { if (Input.GetButtonDown("Fire2")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray)) { print(ray.origin); tempLocation = ray.origin; tempLocation = new Vector3(tempLocation.x, 0, tempLocation.z); goToMouse = true; } } } }
public virtual bool Attach(GameObject obj) { if (obj == null) { return(false); } if (attachedObjects.Contains(obj)) { return(true); } if (CanAttach(obj) != CheckResult.VALID) { return(false); } if (obj.container != null && !obj.container.Remove(obj)) { return(false); } attachedObjects.Add(obj); obj.SetContainer(this); ObjectAttached?.Invoke(obj); return(true); }