Enemy added + new Music Jams added
This commit is contained in:
34
Assets/AssetsFORELLE/Script/Enemy.cs
Normal file
34
Assets/AssetsFORELLE/Script/Enemy.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/AssetsFORELLE/Script/Enemy.cs.meta
generated
Normal file
11
Assets/AssetsFORELLE/Script/Enemy.cs.meta
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f90e1f9169948b4499e0a5541c86d7bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user