Enemy added + new Music Jams added

This commit is contained in:
GungHolo
2023-05-21 17:47:39 +02:00
parent a10e301731
commit 687ee48f65
6 changed files with 288 additions and 95 deletions

View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float maxSpeed;
private Rigidbody2D rb;
private CapsuleCollider2D cc;
private SpriteRenderer sr;
void Start()
{
rb = GetComponent<Rigidbody2D>();
cc = GetComponent<CapsuleCollider2D>();
sr = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void FixedUpdate()
{
rb.velocity = new Vector2(maxSpeed, rb.velocity.y);
}
void OnTriggerEnter2D(Collider2D cc)
{
if (!cc.gameObject.CompareTag("Player"))
{
maxSpeed = -maxSpeed;
sr.flipX = !sr.flipX;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f90e1f9169948b4499e0a5541c86d7bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: