We got fast fuckers now

This commit is contained in:
2024-10-27 20:43:41 -07:00
parent 773a30a6b9
commit 49937d80b5
7 changed files with 246 additions and 8 deletions

View File

@@ -10,28 +10,33 @@ public class Ratbot : MonoBehaviour
public static GameState gameState;
public static GameObject player;
public Rigidbody2D controller;
void Start() {
SetVars();
}
public void SetVars() {
controller = GetComponent<Rigidbody2D>();
// Set gameState and player objects
player = GameObject.FindGameObjectWithTag("Player");
gameState = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameState>();
}
void Update() {
MoveTowardsPlayer();
MoveTowardsPlayer(moveSpeed);
}
public void MoveTowardsPlayer() {
Rigidbody2D controller = GetComponent<Rigidbody2D>();
Vector2 direction = (player.transform.position - transform.position).normalized;
controller.AddRelativeForce(direction*moveSpeed*Time.deltaTime);
public void MoveTowardsPlayer(float speed) {
controller.AddRelativeForce(
(player.transform.position - transform.position)
.normalized
*speed
*Time.deltaTime
);
}
void OnCollisionStay2D(Collision2D collision) {
public virtual void OnCollisionStay2D(Collision2D collision) {
// Deal damage when colliding with the player on a 0.5 second cooldown
if (collision.gameObject.tag != "Player") return;
if (lastDamageTime > Time.fixedTime-damageTimeoutSeconds) return;