movement, automated enemies, automated players, basic abilities
This commit is contained in:
parent
23576e137e
commit
f4344c4700
31 changed files with 4343 additions and 70 deletions
|
|
@ -1,16 +1,30 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AutomatedPlayer : MonoBehaviour
|
||||
public class AutomatedPlayer : AutoControlledEntity
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Player player;
|
||||
public float playerMinDistance;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 direction = new Vector2(0, rb.linearVelocityY);
|
||||
Entity target = player;
|
||||
if (!closestEntity && Vector3.Distance(player.transform.position, transform.position) <= playerMinDistance)
|
||||
{
|
||||
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 * speed;
|
||||
if ((target.transform.position.y - transform.position.y > maxHeightDifference || (DetectWalls() && Vector3.Distance(target.transform.position, transform.position) > minTargetJumpDistance)) && OnGround())
|
||||
{
|
||||
direction.y = jumpPower;
|
||||
}
|
||||
rb.linearVelocity = direction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue