Commit 09d87083 authored by Andrew's avatar Andrew

Barebones EnemyRanged.cs, prefab, and Sprite added.

FPSController given "Player" tag.
"Scripts" folder created to hold EnemyRanged.cs
parent 6509b251
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
# Visual Studio cache directory
.vs/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.opendb
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
# Unity3D Generated File On Crash Reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
\ No newline at end of file
fileFormatVersion: 2
guid: f1412927548e0e7498fa8f74fd63963f
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7178697834341496283
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9022672397112247442}
- component: {fileID: 7178697834341496286}
- component: {fileID: 7178697834341496281}
- component: {fileID: 2334164951446619000}
- component: {fileID: 5628614846504043946}
- component: {fileID: 7178697834341496280}
m_Layer: 0
m_Name: EnemyRanged
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9022672397112247442
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
m_LocalRotation: {x: -0, y: -0.99144495, z: -0, w: -0.13052589}
m_LocalPosition: {x: -0.7, y: 1.78, z: 12.04}
m_LocalScale: {x: 4, y: 4, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: -194.99998, z: 0}
--- !u!212 &7178697834341496286
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 86a0f7fb420c183488725dc158dac91e, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 1
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.64, y: 0.64}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!136 &7178697834341496281
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.18816422
m_Height: 0.6327838
m_Direction: 1
m_Center: {x: 0.04588693, y: 0, z: -2.6832936e-10}
--- !u!114 &2334164951446619000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a7bdc197271574d459491b39874dc4ec, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 50
--- !u!114 &5628614846504043946
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71554234a0af918479894b59b39ce876, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 50
attackRange: 0
bulletPrefab: {fileID: 0}
bulletSpawnPoint: {x: 0, y: 0, z: 0}
bulletDamage: 0
moveSpeed: 0
moveDecisionThreshold: 0
teleportDecisionThreshold: 0
ammoPrefab: {fileID: 0}
insanityRefillAmount: 0
chanceToDropAmmo: 0
player: {fileID: 0}
playerPosition: {x: 0, y: 0, z: 0}
thisTransform: {fileID: 0}
--- !u!54 &7178697834341496280
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697834341496283}
serializedVersion: 2
m_Mass: 100
m_Drag: 0
m_AngularDrag: 0
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
fileFormatVersion: 2
guid: b43a4ef15621158419a2b639f7a98245
folderAsset: yes
DefaultImporter:
guid: ed067dec83bce034eaf619e8635ed09d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
......@@ -147,7 +147,7 @@ Transform:
--- !u!199 &37405688
ParticleSystemRenderer:
serializedVersion: 6
m_ObjectHideFlags: 0
m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
......@@ -5341,6 +5341,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 100000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3}
propertyPath: m_TagString
value: Player
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3}
propertyPath: m_LocalPosition.x
value: 0
......@@ -6063,3 +6067,155 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2334164952670000728
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a7bdc197271574d459491b39874dc4ec, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 50
--- !u!114 &5628614847428448394
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3edb577f02b72d2468f5f4de4f1e46e6, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 50
attackRange: 0
bulletPrefab: {fileID: 0}
bulletSpawnPoint: {x: 0, y: 0, z: 0}
bulletDamage: 0
moveSpeed: 0
moveDecisionThreshold: 0
teleportDecisionThreshold: 0
ammoPrefab: {fileID: 0}
insanityRefillAmount: 0
chanceToDropAmmo: 0
player: {fileID: 0}
playerPosition: {x: 0, y: 0, z: 0}
thisTransform: {fileID: 0}
--- !u!54 &7178697832849809656
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
serializedVersion: 2
m_Mass: 100
m_Drag: 0
m_AngularDrag: 0
m_UseGravity: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!136 &7178697832849809657
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.18816422
m_Height: 0.6327838
m_Direction: 1
m_Center: {x: 0.04588693, y: 0, z: -2.6832936e-10}
--- !u!1 &7178697832849809659
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9022672398070206898}
- component: {fileID: 7178697832849809662}
- component: {fileID: 7178697832849809657}
- component: {fileID: 2334164952670000728}
- component: {fileID: 5628614847428448394}
- component: {fileID: 7178697832849809656}
m_Layer: 0
m_Name: EnemyRanged
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &7178697832849809662
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: f1412927548e0e7498fa8f74fd63963f, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 1
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.64, y: 0.64}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &9022672398070206898
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7178697832849809659}
m_LocalRotation: {x: -0, y: -0.99144495, z: -0, w: -0.13052589}
m_LocalPosition: {x: -0.7, y: 1.78, z: 12.04}
m_LocalScale: {x: 4, y: 4, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: -194.99998, z: 0}
fileFormatVersion: 2
guid: a54c18214345f30418fbc6a2e10b808a
guid: f40e80b041f323445815633754c3b727
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyRanged : MonoBehaviour
{
[Header("Manually-Set Values")]
public float health;
public float attackRange;
[Space(5)]
public GameObject bulletPrefab;
public Vector3 bulletSpawnPoint;
public float bulletDamage;
[Space(5)]
public float moveSpeed;
public float moveDecisionThreshold;
public float teleportDecisionThreshold;
[Space(5)]
public GameObject ammoPrefab;
public float insanityRefillAmount;
public float chanceToDropAmmo;
[Header("Automatically-Set Values")]
[SerializeField] private GameObject player;
public Vector3 playerPosition;
public Transform thisTransform;
/// <summary>
/// Unity calls this function once before Start() (or as soon as a GameObject is made active).
/// </summary>
void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
thisTransform = this.transform;
}
/// <summary>
/// Unity calls this function once before any Update() frames if the GameObject is enabled.
/// </summary>
void Start()
{
}
/// <summary>
/// Unity calls this function every frame.
/// </summary>
void Update()
{
LookAtPlayer();
}
/// <summary>
/// Enemy rotates to look at the player's position.
/// </summary>
void LookAtPlayer()
{
playerPosition = player.transform.position;
Vector3 targetPos = new Vector3(player.transform.position.x, this.transform.position.y, player.transform.position.z);
thisTransform.LookAt(targetPos); // Lock rotation of Y and X axis in Inspector to limit rotation to only left/right.
}
#region Movement
void DecideToMove()
{
// Call this function every frame to compare distance from Player before choosing to Move(), Aim(), as well as Teleport().
// "Vector3.Distance" or "(vector_A - vector_B).magnitude" to get distance between two Transforms
}
void Move()
{
// Call this function if EnemyRanged has decided to move towards the Player.
// Various ways to do this, such as "Vector3.MoveTowards" or "Vector3.Lerp"
}
void Teleport()
{
// Call this function if Player is over "teleportDecisionThreshold" distance away from EnemyRanged.
}
#endregion
#region AimAndFire
void Aim()
{
// Call this function right before firing to return a direction that the Enemy will shoot towards.
// If we let the Aim() change as "playerPosition" changes, the bullets will hone in on Player. We want to grab "playerPosition" at one specific point in time.
}
void ShootBullet()
{
// Call this function when enemy fires at Player -
// instantiate "bulletPrefab" at a specific position "bulletSpawnPoint", fire it in the direction specified by Aim(), and give it X amount of "bulletDamage"
// We also want a system to prevent shooting for a small amount of time after the last shot. You can keep track of time passing with "Time.deltaTime"
}
#endregion
#region health
void CheckHealth()
{
// Call this function every frame for conditionals based on remaining health, such as Die().
}
void Die()
{
// Call this function when health hits 0 -
// add X "insanityRefillAmount" to player's Insanity and have a Y percent "chanceToDropAmmo" of dropping "ammoPrefab"
//player.insanity += insanityRefill; //we don't have a specific name for the Player's insanity variable yet, "player.insanity" is filler. Once we do, add "insanityRefill" to it.
}
#endregion
}
fileFormatVersion: 2
guid: 3edb577f02b72d2468f5f4de4f1e46e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
m_EditorVersion: 2018.3.0f2
m_EditorVersion: 2018.3.5f1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment