Feature: Moving "Enemy"

Added:
- Circular enemy movement pattern
This commit is contained in:
Arlo Filley 2024-04-29 23:54:45 +01:00
parent 0fd0856414
commit cdc25bd8b1
7 changed files with 128 additions and 4 deletions

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}

10
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Unity",
"type": "vstuc",
"request": "attach"
}
]
}

60
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,60 @@
{
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.vs": true,
"**/.gitmodules": true,
"**/.vsconfig": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"Logs/": true,
"logs/": true,
"ProjectSettings/": true,
"UserSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "Mini-Games-Games.sln"
}

View File

@ -1037,7 +1037,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3385535184014867849}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.206068, y: 0.91023076, z: -0.6962841}
m_LocalPosition: {x: 2, y: 0, z: 1}
m_LocalScale: {x: 0.12, y: 0.12, z: 0.12}
m_ConstrainProportionsScale: 1
m_Children:
@ -1084,13 +1084,29 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2715678257314441011}
- component: {fileID: 3385535184014867850}
m_Layer: 0
m_Name: ArachBox
m_Name: Enemy
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &3385535184014867850
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3385535184014867849}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61f2121dbaef51a4aa1fd9032df8ca37, type: 3}
m_Name:
m_EditorClassIdentifier:
speed: 1
range: 4
enemy: {fileID: 2715678257314441011}
--- !u!23 &4126550418253595862
MeshRenderer:
m_ObjectHideFlags: 0

View File

@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class EnemyMovement : MonoBehaviour
{
[Header("Speed")]
public float speed = 2;
public float range = 4;
public Transform enemy;
void Start()
{
}
// Update is called once per frame
void Update()
{
enemy.position = new Vector3(Convert.ToSingle(Math.Cos(Time.time * speed)) * range, 0, Convert.ToSingle(Math.Sin(Time.time * speed)) * range);
}
}

View File

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

View File

@ -40,7 +40,5 @@ public class PlayerMovement : MonoBehaviour
}
// rb.velocity.Set(Vector3.ClampMagnitude(moveDirection, maxSpeed));
speed.Set(rb.velocity.x, rb.velocity.magnitude, rb.velocity.y);
}
}