void FixedUpdate() { if (sineMovement || cosineMovement) { framecount++; sinusoidalAmplitude += data.amplitudeAcceleration * Time.deltaTime; sinusoidalPeriod += data.periodAcceleration * Time.deltaTime; acceleration_senoid_y = new Vector2(0, sinusoidalAmplitude * Mathf.Cos(framecount / (sinusoidalPeriod * 2))); acceleration_senoid_y = HushPuppy.rotateVector(acceleration_senoid_y, angle_grad + 90); if (sineMovement) { acceleration_senoid_y *= -1; } } if (player_direction) { acceleration_player_direction = (player.position - this.transform.position).normalized * player_direction_magnitude; } if (emitter_direction) { acceleration_emitter_direction = (start_position - this.transform.position).normalized * emitter_direction_magnitude; } rb.velocity += (acceleration + acceleration_senoid_y + acceleration_player_direction + acceleration_emitter_direction) * Time.deltaTime * timeSlowModifier; if (rb.velocity.sqrMagnitude > data.maxVelocity) { rb.velocity = rb.velocity.normalized * data.maxVelocity; } if (rb.velocity.magnitude < 0.5 && shouldStopWhenVelocityZero) { rb.velocity = acceleration = Vector2.zero; } if (data.faceVelocity) { float angle = Mathf.Atan2(rb.velocity.y, rb.velocity.x) * Mathf.Rad2Deg; this.transform.rotation = Quaternion.AngleAxis(angle + 90, Vector3.forward); } }
void Update() { if (Application.isEditor && !Application.isPlaying) { emitter = this.GetComponent <CardEmitter>().emitter; player = GameObject.FindGameObjectWithTag("Player").transform; if (shot != null) { angles = getAngles(shot); for (int i = 0; i < angles.Count; i++) { Debug.DrawRay(this.transform.position, HushPuppy.rotateVector(Vector2.up * 3, angles[i]), Color.red, 1f); } } } }