protected override void LateGlobalSuperUpdate() { base.LateGlobalSuperUpdate(); if (fuseLit) { windRotation = SuperMath.ClampAngle(windRotation + 1000.0f * Time.deltaTime); } else { windRotation = SuperMath.ClampAngle(windRotation + 360.0f * Time.deltaTime); } WindTransform.Rotation = Quaternion.Euler(new Vector3(0, 0, windRotation)); if (fuseLit) { if (SuperMath.Timer(fuseLitTime, FuseTimer)) { AnimatedMesh.localScale = Vector3.MoveTowards(AnimatedMesh.localScale, initialScale * 2.0f, 10.0f * Time.deltaTime); } if (SuperMath.Timer(fuseLitTime, FuseTimer + 0.1f)) { currentState = BobOmbStates.Explode; return; } } }
// Update is called once per frame void Update() { Vector3 direction = Math3d.ProjectVectorOnPlane(transform.up, (target.position - transform.position).normalized); if (Vector3.Distance(target.position, transform.position) < SightDistance && Vector3.Angle(direction, transform.forward) > SightAngle) { transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(direction), TurnSpeed * Time.deltaTime); if (!AnimatedMesh.GetComponent <Animation>().IsPlaying("turn")) { AnimatedMesh.GetComponent <Animation>().Play("turn"); GetComponent <AudioSource>().Play(); } } else { if (!AnimatedMesh.GetComponent <Animation>().isPlaying) { AnimatedMesh.GetComponent <Animation>().Play("idle"); } } windRotation = SuperMath.ClampAngle(windRotation + 360.0f * Time.deltaTime); WindTransform.Rotation = Quaternion.Euler(new Vector3(0, 0, windRotation)); }
IEnumerator SpinAnimation() { animating = true; float acceleration = 0; while (true) { acceleration += 700.0f * Time.deltaTime; currentRotation = SuperMath.ClampAngle(currentRotation + acceleration * Time.deltaTime); transform.rotation = Quaternion.AngleAxis(currentRotation, Vector3.down); yield return(0); } }
protected override void LateGlobalSuperUpdate() { //print (this.transform.position.x); // print (this.transform.position.y); // print (this.transform.position.z); hurtPlayer(); if (GameObject.FindObjectOfType <GameMaster> ().raceStarted == true) { Destroy(gameObject); } if (animT) { //print ("cunzais"); } else { //print ("bu"); } animT.wrapMode = WrapMode.Loop; //animT.CrossFade ("walking_inPlace"); //Debug.Log ("animated"); base.LateGlobalSuperUpdate(); if (fuseLit) { windRotation = SuperMath.ClampAngle(windRotation + 1000.0f * Time.deltaTime); } else { windRotation = SuperMath.ClampAngle(windRotation + 360.0f * Time.deltaTime); } if (fuseLit) { if (SuperMath.Timer(fuseLitTime, FuseTimer)) { AnimatedMesh.localScale = Vector3.MoveTowards(AnimatedMesh.localScale, initialScale * 2.0f, 10.0f * Time.deltaTime); } if (SuperMath.Timer(fuseLitTime, FuseTimer + 0.1f)) { currentState = BobOmbStates.Explode; return; } } }
void Update() { if (Hovered || animating) { HoverParticles.enableEmission = true; transform.localScale = Vector3.MoveTowards(transform.localScale, initialScale * ScaleAmount, ScaleAmount / ScaleTime * Time.deltaTime); currentRotation = SuperMath.ClampAngle(currentRotation + RotationSpeed * Time.deltaTime); } else { HoverParticles.enableEmission = false; transform.localScale = Vector3.MoveTowards(transform.localScale, initialScale, ScaleAmount / ScaleTime * Time.deltaTime); if (currentRotation != 0) { currentRotation = Mathf.MoveTowards(currentRotation, 360.0f, RotationSpeed * Time.deltaTime); } } transform.rotation = Quaternion.AngleAxis(currentRotation, Vector3.down); }
void LateUpdate() { var height = Mathf.Lerp(MinHeight, MaxHeight, currentCameraPosition); var maxHeight = Mathf.Lerp(MinMaximumJumpHeight, MaxMaximumJumpHeight, currentCameraPosition); var maxHeightAdjustment = Mathf.Lerp(MinMaxHeightAdjustment, MaxMaxHeightAdjustment, currentCameraPosition); var distance = Mathf.Lerp(MinDistance, MaxDistance, currentCameraPosition); var angle = Mathf.Lerp(MinAngle, MaxAngle, currentCameraPosition); var weight = Mathf.Lerp(MinDampWeight, MaxDampWeight, currentCameraPosition); Vector3 targetPoint = target.position; if (mario.StateCompare(MarioMachine.MarioStates.Hang) || mario.StateCompare(MarioMachine.MarioStates.Climb)) { targetPoint = mario.ClimbTarget(); if (!planarDamping) { SetPlanarDamping(true); } } else { if (planarDamping) { SetPlanarDamping(false); } } if (!mario.Airborn()) { liftoffPoint = targetPoint; verticalPosition = Vector3.SmoothDamp(verticalPosition, Math3d.ProjectPointOnLine(Vector3.zero, controller.up, targetPoint + height * controller.up), ref currentDampVelocity, 0.2f); currentRotationVertical = Mathf.SmoothDamp(currentRotationVertical, 0, ref currentRotationVelocity, 0.2f); } else { Vector3 groundPosition = Math3d.ProjectPointOnLine(Vector3.zero, controller.up, liftoffPoint); Vector3 airPosition = Math3d.ProjectPointOnLine(Vector3.zero, controller.up, targetPoint); float jumpHeight = Vector3.Distance(groundPosition, airPosition); var dropRotation = Mathf.Lerp(MinDropRotation, MaxDropRotation, Mathf.InverseLerp(MinDropDistance, MaxDropDistance, jumpHeight)); if (SuperMath.PointAbovePlane(controller.up, liftoffPoint, targetPoint)) { float extraJumpHeight = 0; if (jumpHeight > maxHeight) { extraJumpHeight = Mathf.Clamp(jumpHeight - maxHeight, 0, maxHeightAdjustment); } verticalPosition = Vector3.SmoothDamp(verticalPosition, groundPosition + controller.up * ((jumpHeight * weight) + height + extraJumpHeight), ref currentDampVelocity, 0.1f); } else if (SuperMath.PointAbovePlane(controller.up, liftoffPoint - controller.up * MinDropDistance, targetPoint)) { verticalPosition = Vector3.SmoothDamp(verticalPosition, Math3d.ProjectPointOnLine(Vector3.zero, controller.up, targetPoint + height * controller.up), ref currentDampVelocity, 0.1f); } else { currentRotationVertical = Mathf.SmoothDamp(currentRotationVertical, dropRotation, ref currentRotationVelocity, 0.5f); } } Vector3 direction = Math3d.ProjectVectorOnPlane(controller.up, (targetPoint - transform.position).normalized); float angleAdjustment = Vector3.Angle(direction, Math3d.ProjectVectorOnPlane(controller.up, transform.forward)); if (!AutoTrack) { angleAdjustment = 0; } angleAdjustment = SuperMath.PointAbovePlane(transform.right, transform.position, targetPoint) ? angleAdjustment : -angleAdjustment; currentRotationHorizontal = SuperMath.ClampAngle(currentRotationHorizontal - input.Current.CameraInput.x * XSensitivity + angleAdjustment); transform.rotation = Quaternion.AngleAxis(currentRotationHorizontal, controller.up); currentCameraPosition = Mathf.Clamp(currentCameraPosition - input.Current.CameraInput.y * YSensitivity, 0, 1); if (planarDamping) { planarPosition = Vector3.SmoothDamp(planarPosition, Math3d.ProjectPointOnPlane(controller.up, Vector3.zero, targetPoint), ref planarDampVelocity, 0.2f); } else { planarPosition = Math3d.ProjectPointOnPlane(controller.up, Vector3.zero, targetPoint); } transform.position = planarPosition + verticalPosition - transform.forward * distance + cameraShakePosition + constantShakePosition; transform.rotation = Quaternion.AngleAxis(angle + currentRotationVertical, transform.right) * transform.rotation; currentShakeMagnitude = 0; }