void OnTriggerEnter(Collider col) { if (col.gameObject.tag != "Converser") { return; } mover = col.GetComponent <SimpleMover>(); seeker = col.GetComponent <SimpleSeek>(); originalMaxSpeed = mover.maxSpeed; originalMaxSpeed = mover.maxSpeed; Vector3 pushDirection = col.gameObject.transform.position - transform.position; mover.maxSpeed = 50; mover.Move(pushDirection, mover.maxSpeed); if (seeker != null) { seeker.enabled = false; } if (!cooldown) { cooldown = true; } }
void Update() { // Set speed proportional to head's speed to slowly wait for yield proximity. Vector3 targetPos = partnerLink.transform.position - new Vector3(0, 0, (transform.localScale.z / 2)); Vector3 fromHead = transform.position - targetPos; float fromHeadDistance = fromHead.magnitude; fromHead.z = 0; float yieldProximityPortion = fromHeadDistance / partnerLink.startYieldProximity; float targetSpeed = partnerLink.mover.maxSpeed; mover.maxSpeed = Mathf.Min(targetSpeed * (yieldProximityPortion / 2), fromHeadDistance / Time.deltaTime); mover.externalSpeedMultiplier = partnerLink.mover.externalSpeedMultiplier; mover.Move(-fromHead, mover.maxSpeed); if (following) { // If tail can be turned off, fade as it approaches trigger. if (trigger.enabled) { Color color = renderer.material.color; color.a = yieldProximityPortion; if (partnerLink.tracer.lineRenderer != null) { Color nearColor = renderer.material.color; nearColor.a = Mathf.Min(yieldProximityPortion, 1); Color farColor = renderer.material.color; farColor.a = 0; partnerLink.tracer.lineRenderer.SetColors(farColor, nearColor); partnerLink.tracer.lineRenderer.SetWidth(((1 - yieldProximityPortion) * partnerLink.tracer.trailNearWidth) + (yieldProximityPortion * partnerLink.tracer.trailFarWidth), partnerLink.tracer.trailNearWidth); } } // Render and align to movement. renderer.enabled = true; renderer.material.color = colorMimicTarget.renderer.material.color; if (fromHead.sqrMagnitude > 0) { // Rotated around world z axis to look at target position. float angle = Helper.AngleDegrees(transform.forward, -fromHead, Vector3.forward); transform.Rotate(Vector3.forward, angle, Space.World); } } else { renderer.enabled = false; } }
void OnTriggerEnter(Collider col) { if(col.gameObject.tag != "Converser") return; mover = col.GetComponent<SimpleMover>(); seeker = col.GetComponent<SimpleSeek>(); originalMaxSpeed = mover.maxSpeed; originalMaxSpeed = mover.maxSpeed; Vector3 pushDirection = col.gameObject.transform.position - transform.position; mover.maxSpeed = 50; mover.Move(pushDirection, mover.maxSpeed); if(seeker != null) seeker.enabled = false; if(!cooldown) cooldown = true; }
private void Drag(bool criticalLine = true) { Vector3 dragForward = MousePointInWorld() - transform.position; if (useController) { dragForward = cursor.GetComponent <ControllerSeek>().forward; } if (directVelocity) { mover.Move(dragForward, mover.maxSpeed, true); } else { mover.Accelerate(dragForward); } if (tracer != null) { tracer.AddVertex(transform.position); } }