private void Update() { if (target && targetVulnerable) { Vector3 direction = (target.transform.position - transform.position).normalized; projectileMovement.UpdateRotation(CS_Utils.PointToDegree(direction)); } }
void Update() { float angle = CS_Utils.PointToDegree(target.position - rotateObject.position); if (rotateObject) { rotateObject.rotation = Quaternion.Euler(0.0f, 0.0f, angle + 90); } timer -= Time.deltaTime; if (timer <= 0) { CS_Projectile_Movement i = Instantiate(projectile, spawnLocation.position, spawnLocation.rotation, parent); i.angle = angle; i.speed = projectileSpeed; timer = spawnRate; } }
public override void SpecialCollision(Collision2D collision) { Rigidbody2D rb = GetComponent <Rigidbody2D>(); CS_Projectile_Collision pc = GetComponent <CS_Projectile_Collision>(); float magnitude = rb.velocity.magnitude; float angle = CS_Utils.PointToDegree(rb.velocity); CS_Projectile_Collision.Owner owner = pc.GetOwner(); float angle1 = (angle + 45); Vector2 velocity1 = CS_Utils.DegreeToPoint(angle1); CreateChild(velocity1, magnitude, owner); float angle2 = (angle - 45); Vector2 velocity2 = CS_Utils.DegreeToPoint(angle2); CreateChild(velocity2, magnitude, owner); Destroy(gameObject); }
void Update() { if (deathAnimation.enabled == true) { deathTimer -= Time.deltaTime; if (deathTimer <= 0) { Destroy(this.gameObject); } } else { float distans = Vector3.Distance(transform.position, player.transform.position); float angle = CS_Utils.PointToDegree(player.position - this.transform.position); this.transform.rotation = Quaternion.Euler(0.0f, 0.0f, angle); if (distans <= 20) { shotDelay -= Time.deltaTime; //spotted.Play(); if (shotDelay <= 0) { for (int index = 0; index < cannons.Length; index++) { cannonBall.transform.position = cannons[index].position; GameObject temp = Instantiate(cannonBall); Rigidbody2D rb = temp.GetComponent <Rigidbody2D>(); rb.velocity = (transform.right * cannonSpeed); shotDelay = 3; Instantiate(cannonSmoke, cannons[index].transform.position, Quaternion.LookRotation(rightCannonAimPositions[index].transform.position - cannons[index].transform.position)); } } } } }
private void OnCollisionExit2D(Collision2D collision) { UpdateRotation(CS_Utils.PointToDegree(rb.velocity.normalized)); }
void Update() { float angle = CS_Utils.PointToDegree(target.position - rotateObject.position); rotateObject.rotation = Quaternion.Euler(0.0f, 0.0f, angle + 90); }
private IEnumerator UpdatePreviousAngle() { yield return(new WaitForEndOfFrame()); previousAngle = CS_Utils.PointToDegree(rb.velocity); }