uh you can switch players now
This commit is contained in:
parent
a0bfc600ef
commit
cb4470f2d6
11 changed files with 582 additions and 235 deletions
|
|
@ -21,22 +21,26 @@ public class AutomatedPlayer : AutoControlledEntity
|
|||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
Entity target = player;
|
||||
if (!closestEntity && Vector3.Distance(player.transform.position, transform.position) <= playerMinDistance)
|
||||
if (!stats.isStalled)
|
||||
{
|
||||
stats.rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess
|
||||
return; //do not bother running any more code lol you're already next to the player and no enemies nearby
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
Entity target = player;
|
||||
if (!closestEntity && Vector3.Distance(player.transform.position, transform.position) <= playerMinDistance)
|
||||
{
|
||||
stats.rb.linearVelocity = direction; //repeated code sucks but it works in this case i guess
|
||||
return; //do not bother running any more code lol you're already next to the player and no enemies nearby
|
||||
}
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
target = closestEntity;
|
||||
}
|
||||
direction.x = (target.transform.position - transform.position).normalized.x * stats.speed;
|
||||
if (/*(target.transform.position.y - transform.position.y > maxHeightDifference ||*/ (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)/*)*/ && stats.OnGround())
|
||||
{
|
||||
direction.y = stats.jumpPower;
|
||||
}
|
||||
FlipSprite(direction);
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
target = closestEntity;
|
||||
}
|
||||
direction.x = (target.transform.position - transform.position).normalized.x * stats.speed;
|
||||
if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && stats.OnGround())
|
||||
{
|
||||
direction.y = stats.jumpPower;
|
||||
}
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue