We got fast fuckers now
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user