Feature: Enemy collision detection, and customisable keybinds
Added: - Enemy collision detection - Customisable movement keybinds - Simplified movement code
This commit is contained in:
parent
cdc25bd8b1
commit
4e9e988034
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -56,5 +56,5 @@
|
|||||||
"temp/": true,
|
"temp/": true,
|
||||||
"Temp/": true
|
"Temp/": true
|
||||||
},
|
},
|
||||||
"dotnet.defaultSolution": "Mini-Games-Games.sln"
|
"dotnet.defaultSolution": "Mini-Games-Game.sln"
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ RenderSettings:
|
|||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 705507994}
|
m_Sun: {fileID: 705507994}
|
||||||
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
|
m_IndirectSpecularColor: {r: 0.18028326, g: 0.22571333, b: 0.30692202, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
@ -123,103 +123,6 @@ NavMeshSettings:
|
|||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
--- !u!1 &84224833
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 84224837}
|
|
||||||
- component: {fileID: 84224836}
|
|
||||||
- component: {fileID: 84224835}
|
|
||||||
- component: {fileID: 84224834}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Boobies
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!65 &84224834
|
|
||||||
BoxCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 84224833}
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Size: {x: 1, y: 1, z: 1}
|
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!23 &84224835
|
|
||||||
MeshRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 84224833}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_CastShadows: 1
|
|
||||||
m_ReceiveShadows: 1
|
|
||||||
m_DynamicOccludee: 1
|
|
||||||
m_StaticShadowCaster: 0
|
|
||||||
m_MotionVectors: 1
|
|
||||||
m_LightProbeUsage: 1
|
|
||||||
m_ReflectionProbeUsage: 1
|
|
||||||
m_RayTracingMode: 2
|
|
||||||
m_RayTraceProcedural: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 10303, 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_ReceiveGI: 1
|
|
||||||
m_PreserveUVs: 0
|
|
||||||
m_IgnoreNormalsForChartDetection: 0
|
|
||||||
m_ImportantGI: 0
|
|
||||||
m_StitchLightmapSeams: 1
|
|
||||||
m_SelectedEditorRenderState: 3
|
|
||||||
m_MinimumChartSize: 4
|
|
||||||
m_AutoUVMaxDistance: 0.5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_AdditionalVertexStreams: {fileID: 0}
|
|
||||||
--- !u!33 &84224836
|
|
||||||
MeshFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 84224833}
|
|
||||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
--- !u!4 &84224837
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 84224833}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0.027415752, y: 0.95, z: -0.016391277}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 5
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &441602406
|
--- !u!1 &441602406
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -233,7 +136,7 @@ GameObject:
|
|||||||
- component: {fileID: 441602408}
|
- component: {fileID: 441602408}
|
||||||
- component: {fileID: 441602407}
|
- component: {fileID: 441602407}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Plane
|
m_Name: Ground
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -312,7 +215,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 441602406}
|
m_GameObject: {fileID: 441602406}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 5, y: 5, z: 5}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
@ -508,10 +411,10 @@ GameObject:
|
|||||||
- component: {fileID: 1261174832}
|
- component: {fileID: 1261174832}
|
||||||
- component: {fileID: 1261174831}
|
- component: {fileID: 1261174831}
|
||||||
- component: {fileID: 1261174830}
|
- component: {fileID: 1261174830}
|
||||||
- component: {fileID: 1261174829}
|
|
||||||
- component: {fileID: 1261174834}
|
- component: {fileID: 1261174834}
|
||||||
|
- component: {fileID: 1261174829}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Cube
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -537,7 +440,11 @@ MonoBehaviour:
|
|||||||
rb: {fileID: 1261174834}
|
rb: {fileID: 1261174834}
|
||||||
drag: 3
|
drag: 3
|
||||||
orientation: {fileID: 1261174833}
|
orientation: {fileID: 1261174833}
|
||||||
speed: {x: 0, y: 0, z: 0}
|
speed: 5
|
||||||
|
forwardKey: 44
|
||||||
|
backwardKey: 111
|
||||||
|
leftKey: 97
|
||||||
|
rightKey: 101
|
||||||
--- !u!65 &1261174830
|
--- !u!65 &1261174830
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
52
Assets/Scripts/PlayerController.cs
Normal file
52
Assets/Scripts/PlayerController.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class PlayerController : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Keybinds")]
|
||||||
|
public KeyCode forwardKey = KeyCode.W;
|
||||||
|
public KeyCode backwardKey = KeyCode.S;
|
||||||
|
public KeyCode leftKey = KeyCode.A;
|
||||||
|
public KeyCode rightKey = KeyCode.D;
|
||||||
|
|
||||||
|
[Header("Speed")]
|
||||||
|
public float speed = 5;
|
||||||
|
|
||||||
|
[Header("Player Object")]
|
||||||
|
public Vector3 moveDirection;
|
||||||
|
public Rigidbody rb;
|
||||||
|
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
rb = GetComponent<Rigidbody>();
|
||||||
|
rb.freezeRotation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
moveDirection = PlayerInput();
|
||||||
|
|
||||||
|
rb.velocity = moveDirection.normalized * speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 PlayerInput()
|
||||||
|
{
|
||||||
|
float forward = Convert.ToSingle(Input.GetKey(forwardKey));
|
||||||
|
float backward = Convert.ToSingle(Input.GetKey(backwardKey));
|
||||||
|
float right = Convert.ToSingle(Input.GetKey(rightKey));
|
||||||
|
float left = Convert.ToSingle(Input.GetKey(leftKey));
|
||||||
|
return new Vector3(right - left, 0, forward - backward);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCollisionEnter(Collision collision)
|
||||||
|
{
|
||||||
|
if (collision.gameObject.name == "Enemy")
|
||||||
|
{
|
||||||
|
Debug.Log("OWIE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class PlayerMovement : MonoBehaviour
|
|
||||||
{
|
|
||||||
[Header("Speed")]
|
|
||||||
public float acceleration;
|
|
||||||
public float maxSpeed;
|
|
||||||
|
|
||||||
[Header("Movement")]
|
|
||||||
public float horizontalInput;
|
|
||||||
public float verticalInput;
|
|
||||||
public Vector3 moveDirection;
|
|
||||||
public Rigidbody rb;
|
|
||||||
public float drag;
|
|
||||||
public Transform orientation;
|
|
||||||
public Vector3 speed;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
rb = GetComponent<Rigidbody>();
|
|
||||||
rb.freezeRotation = true;
|
|
||||||
rb.drag = drag;
|
|
||||||
speed = new Vector3(0f, 0f, 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
horizontalInput = Input.GetAxisRaw("Horizontal");
|
|
||||||
verticalInput = Input.GetAxisRaw("Vertical");
|
|
||||||
moveDirection = orientation.forward * verticalInput + orientation.up * 0 + orientation.right * horizontalInput;
|
|
||||||
moveDirection = moveDirection.normalized * acceleration;
|
|
||||||
|
|
||||||
rb.AddForce(moveDirection);
|
|
||||||
|
|
||||||
if (rb.velocity.magnitude > maxSpeed)
|
|
||||||
{
|
|
||||||
rb.velocity = rb.velocity.normalized * maxSpeed;
|
|
||||||
}
|
|
||||||
// rb.velocity.Set(Vector3.ClampMagnitude(moveDirection, maxSpeed));
|
|
||||||
speed.Set(rb.velocity.x, rb.velocity.magnitude, rb.velocity.y);
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,15 +15,19 @@ MonoBehaviour:
|
|||||||
version: 11
|
version: 11
|
||||||
--- !u!21 &2100000
|
--- !u!21 &2100000
|
||||||
Material:
|
Material:
|
||||||
serializedVersion: 6
|
serializedVersion: 8
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: Prototype_512x512_Grey2
|
m_Name: Prototype_512x512_Grey2
|
||||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_ShaderKeywords: _DISABLE_SSR_TRANSPARENT _NORMALMAP _NORMALMAP_TANGENT_SPACE
|
m_ValidKeywords:
|
||||||
_SPECULARHIGHLIGHTS_OFF
|
- _NORMALMAP
|
||||||
|
- _SPECULARHIGHLIGHTS_OFF
|
||||||
|
m_InvalidKeywords:
|
||||||
|
- _DISABLE_SSR_TRANSPARENT
|
||||||
|
- _NORMALMAP_TANGENT_SPACE
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
@ -175,6 +179,7 @@ Material:
|
|||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _AORemapMax: 1
|
- _AORemapMax: 1
|
||||||
- _AORemapMin: 0
|
- _AORemapMin: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user