moved stuff to a different entity script
This commit is contained in:
parent
f4344c4700
commit
a0bfc600ef
14 changed files with 497 additions and 189 deletions
|
|
@ -5,19 +5,19 @@ public class Enemy : AutoControlledEntity
|
|||
{
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 direction = new Vector2(0, rb.linearVelocityY);
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
direction.x = (closestEntity.transform.position - transform.position).normalized.x * speed;
|
||||
if ((closestEntity.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(closestEntity.transform.position, transform.position) > minTargetJumpDistance)) && OnGround())
|
||||
direction.x = (closestEntity.transform.position - transform.position).normalized.x * stats.speed;
|
||||
if ((closestEntity.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(closestEntity.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround())
|
||||
{
|
||||
direction.y = jumpPower;
|
||||
direction.y = stats.jumpPower;
|
||||
}
|
||||
}
|
||||
rb.linearVelocity = direction;
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
|
||||
protected override void OnDeath()
|
||||
public override void OnDeath()
|
||||
{
|
||||
base.OnDeath();
|
||||
Destroy(gameObject);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue