Did some work
This commit is contained in:
@ -10,6 +10,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 4476842061966021075}
|
||||
- component: {fileID: 2981135554967256007}
|
||||
- component: {fileID: 1540579659150390887}
|
||||
- component: {fileID: 7146678828090736945}
|
||||
m_Layer: 0
|
||||
m_Name: Generation
|
||||
m_TagString: Untagged
|
||||
@ -84,3 +86,37 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &1540579659150390887
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1458536803320539101}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6d151e6102b72db4590ce83309573f1c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
PathGameObject: {fileID: 0}
|
||||
--- !u!50 &7146678828090736945
|
||||
Rigidbody2D:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1458536803320539101}
|
||||
m_BodyType: 0
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDrag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_GravityScale: 0
|
||||
m_Material: {fileID: 0}
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
|
@ -491,7 +491,7 @@ GameObject:
|
||||
- component: {fileID: 1292283378}
|
||||
- component: {fileID: 1292283377}
|
||||
m_Layer: 0
|
||||
m_Name: Pathing
|
||||
m_Name: Path
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -509,6 +509,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 62f8cdc29b6f43e4998a2750b3b9a023, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
waypointPrefab: {fileID: 2624247600710686983, guid: fad75b8b6a5d5a6468eef0f0782ea835, type: 3}
|
||||
enemyPrefab: {fileID: 1458536803320539101, guid: f1eab3cea41682c4ba2ff7c2b218fc0b, type: 3}
|
||||
--- !u!4 &1292283378
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1,13 +1,24 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GenerationController : MonoBehaviour
|
||||
{
|
||||
public class GenerationController : MonoBehaviour {
|
||||
|
||||
public GameObject PathGameObject;
|
||||
private Rigidbody2D rb;
|
||||
|
||||
int pathIndex = 0;
|
||||
|
||||
bool moving = false;
|
||||
|
||||
private GameObject pathPointer;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
PathGameObject = GameObject.Find("Path");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -15,4 +26,22 @@ public class GenerationController : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate() {
|
||||
pathPointer = PathGameObject.GetComponent<PathingController>().waypointList[pathIndex] as GameObject;
|
||||
|
||||
if (!moving) {
|
||||
Vector2 force = new Vector2(pathPointer.transform.position.x, pathPointer.transform.position.y);
|
||||
rb.AddForce(force);
|
||||
moving = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D col) {
|
||||
if (col.gameObject == pathPointer) {
|
||||
moving = false;
|
||||
pathIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,25 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PathingController : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public class PathingController : MonoBehaviour {
|
||||
|
||||
public GameObject waypointPrefab;
|
||||
public ArrayList waypointList = new ArrayList();
|
||||
|
||||
public GameObject enemyPrefab;
|
||||
|
||||
private ArrayList enemyList = new ArrayList();
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
waypointList.Add(Instantiate(waypointPrefab, new Vector3(0, 0, 0), Quaternion.identity));
|
||||
waypointList.Add(Instantiate(waypointPrefab, new Vector3(0, 5, 0), Quaternion.identity));
|
||||
waypointList.Add(Instantiate(waypointPrefab, new Vector3(5, 5, 0), Quaternion.identity));
|
||||
|
||||
}
|
||||
|
||||
@ -18,4 +28,17 @@ public class PathingController : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate() {
|
||||
if (counter == 0) {
|
||||
enemyList.Add(Instantiate(enemyPrefab));
|
||||
counter++;
|
||||
}
|
||||
else if (counter >= 50) {
|
||||
counter = 0;
|
||||
}
|
||||
else {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user