IEnumerator jumper() { while (true) { yield return(new WaitForSeconds(Random.Range(0.01f, 1f))); var angle = Random.insideUnitSphere; var scale = Random.Range(0.000001f, 0.001f); angle.Scale(scale); Rigidbody push = SentientListener.randomProp().GetComponent <Rigidbody>(); push.AddForce(angle, ForceMode.VelocityChange); push.AddTorque(Random.insideUnitSphere.Scale(Random.Range(0, 0.3f)), ForceMode.VelocityChange); } }
//TODO geiger void Awake() { spring = gameObject.AddComponent <SpringJoint>(); spring.spring = 100f; spring.damper = 10f; //spring.minDistance = 0.01f; spring.autoConfigureConnectedAnchor = false; GetComponent <Rigidbody>().isKinematic = true; hand = transform.GetComponentInParent <Hand>() ?? transform.GetComponent <Hand>(); GameObject randObj = SentientListener.randomProp(); spring.connectedBody = randObj.GetComponent <Rigidbody>(); //setTarget(randObj); }
public void setTarget(GameObject target) { if (this.target == target) { Debug.LogError("tried to re-set a target prop"); return; } if (this.target != null) { score += 1; scoreObj.text = score.ToString(); Destroy(this.target.GetComponent <SentientListener>()); //this.target.AddComponent<Zombify>(); } this.target = target; highlight.transform.parent = target.transform; highlight.transform.localPosition = Vector3.zero; spring.connectedBody = target.GetComponent <Rigidbody>(); top = Vector3.zero; foreach (var collider in target.GetComponents <Collider>()) { var newTop = collider.getTop(); if (top == Vector3.zero || top.y < newTop.y) { top = newTop; } } spring.connectedAnchor = top; SentientListener listener = target.gameObject.AddComponent <SentientListener>(); listener.controller = this; }