Add player controls and trail
This commit is contained in:
8
Assets/Input.meta
Normal file
8
Assets/Input.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 001437dd04ce9f34f9a2f4218faffdbf
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
95
Assets/Input/PlayerInputAction.inputactions
Normal file
95
Assets/Input/PlayerInputAction.inputactions
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"name": "PlayerInputAction",
|
||||||
|
"maps": [
|
||||||
|
{
|
||||||
|
"name": "PlayerActionMap",
|
||||||
|
"id": "24041b7e-f815-46bf-9c8b-81e9a5ab7c5e",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"name": "Move",
|
||||||
|
"type": "Value",
|
||||||
|
"id": "f1ff6d89-1124-48d9-adeb-4d2611c44344",
|
||||||
|
"expectedControlType": "Vector2",
|
||||||
|
"processors": "",
|
||||||
|
"interactions": "",
|
||||||
|
"initialStateCheck": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bindings": [
|
||||||
|
{
|
||||||
|
"name": "2D Vector",
|
||||||
|
"id": "17de45ba-ea40-4026-bf81-402f895fd042",
|
||||||
|
"path": "2DVector(mode=1)",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Move",
|
||||||
|
"isComposite": true,
|
||||||
|
"isPartOfComposite": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "up",
|
||||||
|
"id": "8b49146a-0d04-45f9-80ae-efa389d56678",
|
||||||
|
"path": "",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Move",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "down",
|
||||||
|
"id": "8ea7eec0-0813-46aa-8c78-db89e7c46877",
|
||||||
|
"path": "",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "",
|
||||||
|
"action": "Move",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "left",
|
||||||
|
"id": "d37f3018-f4ff-4f7f-9444-b12ca71d7cae",
|
||||||
|
"path": "<Keyboard>/a",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Main Control Scheme",
|
||||||
|
"action": "Move",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "right",
|
||||||
|
"id": "406b8672-32e4-4995-9650-70284671aa65",
|
||||||
|
"path": "<Keyboard>/d",
|
||||||
|
"interactions": "",
|
||||||
|
"processors": "",
|
||||||
|
"groups": "Main Control Scheme",
|
||||||
|
"action": "Move",
|
||||||
|
"isComposite": false,
|
||||||
|
"isPartOfComposite": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"controlSchemes": [
|
||||||
|
{
|
||||||
|
"name": "Main Control Scheme",
|
||||||
|
"bindingGroup": "Main Control Scheme",
|
||||||
|
"devices": [
|
||||||
|
{
|
||||||
|
"devicePath": "<Keyboard>",
|
||||||
|
"isOptional": false,
|
||||||
|
"isOR": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"devicePath": "<Mouse>",
|
||||||
|
"isOptional": false,
|
||||||
|
"isOR": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
14
Assets/Input/PlayerInputAction.inputactions.meta
Normal file
14
Assets/Input/PlayerInputAction.inputactions.meta
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6bacd21b778138d44b3c0068ed90895f
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
|
generateWrapperCode: 0
|
||||||
|
wrapperCodePath:
|
||||||
|
wrapperClassName:
|
||||||
|
wrapperCodeNamespace:
|
||||||
8
Assets/Materials.meta
Normal file
8
Assets/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17758df3ad5333949888d22336bc7119
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
80
Assets/Materials/Ground.mat
Normal file
80
Assets/Materials/Ground.mat
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Ground
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 0.3018868, g: 0.29191884, b: 0.29191884, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
||||||
8
Assets/Materials/Ground.mat.meta
Normal file
8
Assets/Materials/Ground.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 671a54aed03aa184a867efb01293adc7
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -47,6 +47,6 @@ public class GameManager : MonoBehaviour
|
|||||||
|
|
||||||
public void IncrementScore(int val)
|
public void IncrementScore(int val)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,73 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
public class Player : MonoBehaviour
|
public class Player : MonoBehaviour
|
||||||
{
|
{
|
||||||
public int health;
|
public float health;
|
||||||
public float speed;
|
public float speed;
|
||||||
public float trailLength;
|
public float trailLength;
|
||||||
public ParticleSystem trail;
|
public GameObject trail;
|
||||||
|
public float rotationSpeed;
|
||||||
|
public float direction;
|
||||||
|
public List<ParticleCollisionEvent> collisionEvents;
|
||||||
|
public bool isLit;
|
||||||
|
|
||||||
|
public Camera camera;
|
||||||
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
collisionEvents = new List<ParticleCollisionEvent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void OnMove(InputValue value)
|
||||||
|
{
|
||||||
|
Vector2 inputVector = value.Get<Vector2>();
|
||||||
|
direction = inputVector.x;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//if isLit decrease health
|
||||||
|
if (isLit)
|
||||||
|
{
|
||||||
|
health -= 100.0f * Time.deltaTime;
|
||||||
|
Debug.Log("Health: " + health);
|
||||||
|
}
|
||||||
|
|
||||||
|
//move player forward
|
||||||
|
transform.position += transform.forward * speed * Time.deltaTime;
|
||||||
|
//rotate based on direction
|
||||||
|
transform.Rotate(0, direction * rotationSpeed * 2 * Time.deltaTime, 0);
|
||||||
|
|
||||||
|
float horzExtent = camera.orthographicSize * Screen.width / Screen.height;
|
||||||
|
float vertExtent = camera.orthographicSize;
|
||||||
|
|
||||||
|
if (transform.position.z > vertExtent)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(transform.position.x, transform.position.y, -vertExtent);
|
||||||
|
}
|
||||||
|
else if (transform.position.z < -vertExtent)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(transform.position.x, transform.position.y, vertExtent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transform.position.x > horzExtent)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(-horzExtent, transform.position.y, transform.position.z);
|
||||||
|
}
|
||||||
|
else if (transform.position.x < -horzExtent)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(horzExtent, transform.position.y, transform.position.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DecreaseTrail(float val)
|
public void DecreaseTrail(float val)
|
||||||
@@ -31,11 +80,12 @@ public class Player : MonoBehaviour
|
|||||||
//Increate trail length
|
//Increate trail length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnParticleCollision(GameObject other)
|
private void OnParticleCollision(GameObject other)
|
||||||
{
|
{
|
||||||
if (other == trail)
|
if (other == trail)
|
||||||
{
|
{
|
||||||
//Hit by trail
|
//Debug.Log(other.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
Assets/Scripts/Game/Trail.cs
Normal file
35
Assets/Scripts/Game/Trail.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Trail : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Player player;
|
||||||
|
private ParticleSystem particleSystem;
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
particleSystem = GetComponent<ParticleSystem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnParticleTrigger()
|
||||||
|
{
|
||||||
|
//BUGBUG: This is a hack to get the particles to work.
|
||||||
|
List<ParticleSystem.Particle> insideList = new List<ParticleSystem.Particle>();
|
||||||
|
int numInside = particleSystem.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, insideList);
|
||||||
|
if (numInside > 0)
|
||||||
|
{
|
||||||
|
player.isLit = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.isLit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Game/Trail.cs.meta
Normal file
11
Assets/Scripts/Game/Trail.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 01382dbef5cd7b3478030187afaadf59
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -17,8 +17,10 @@ public class ParticleTest : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnParticleCollision(GameObject other)
|
private void OnParticleCollision(GameObject other)
|
||||||
{
|
{
|
||||||
Debug.Log(other);
|
Debug.Log(other);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"com.unity.cinemachine": "2.8.4",
|
||||||
"com.unity.collab-proxy": "1.15.15",
|
"com.unity.collab-proxy": "1.15.15",
|
||||||
"com.unity.feature.development": "1.0.1",
|
"com.unity.feature.development": "1.0.1",
|
||||||
"com.unity.ide.rider": "3.0.13",
|
"com.unity.ide.rider": "3.0.13",
|
||||||
"com.unity.ide.visualstudio": "2.0.14",
|
"com.unity.ide.visualstudio": "2.0.14",
|
||||||
"com.unity.ide.vscode": "1.2.5",
|
"com.unity.ide.vscode": "1.2.5",
|
||||||
|
"com.unity.inputsystem": "1.3.0",
|
||||||
"com.unity.test-framework": "1.1.31",
|
"com.unity.test-framework": "1.1.31",
|
||||||
"com.unity.textmeshpro": "3.0.6",
|
"com.unity.textmeshpro": "3.0.6",
|
||||||
"com.unity.timeline": "1.6.4",
|
"com.unity.timeline": "1.6.4",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"com.unity.cinemachine": {
|
||||||
|
"version": "2.8.4",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.collab-proxy": {
|
"com.unity.collab-proxy": {
|
||||||
"version": "1.15.15",
|
"version": "1.15.15",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@@ -62,6 +69,15 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.unity.inputsystem": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.modules.uielements": "1.0.0"
|
||||||
|
},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.performance.profile-analyzer": {
|
"com.unity.performance.profile-analyzer": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ EditorBuildSettings:
|
|||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes: []
|
m_Scenes: []
|
||||||
m_configObjects: {}
|
m_configObjects:
|
||||||
|
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
|
||||||
|
|||||||
@@ -699,7 +699,8 @@ PlayerSettings:
|
|||||||
webGLLinkerTarget: 1
|
webGLLinkerTarget: 1
|
||||||
webGLThreadsSupport: 0
|
webGLThreadsSupport: 0
|
||||||
webGLDecompressionFallback: 0
|
webGLDecompressionFallback: 0
|
||||||
scriptingDefineSymbols: {}
|
scriptingDefineSymbols:
|
||||||
|
Standalone: STARTER_ASSETS_PACKAGES_CHECKED
|
||||||
additionalCompilerArguments: {}
|
additionalCompilerArguments: {}
|
||||||
platformArchitecture: {}
|
platformArchitecture: {}
|
||||||
scriptingBackend: {}
|
scriptingBackend: {}
|
||||||
@@ -787,7 +788,7 @@ PlayerSettings:
|
|||||||
m_VersionCode: 1
|
m_VersionCode: 1
|
||||||
m_VersionName:
|
m_VersionName:
|
||||||
apiCompatibilityLevel: 6
|
apiCompatibilityLevel: 6
|
||||||
activeInputHandler: 0
|
activeInputHandler: 1
|
||||||
cloudProjectId:
|
cloudProjectId:
|
||||||
framebufferDepthMemorylessMode: 0
|
framebufferDepthMemorylessMode: 0
|
||||||
qualitySettingsNames: []
|
qualitySettingsNames: []
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
--- !u!78 &1
|
--- !u!78 &1
|
||||||
TagManager:
|
TagManager:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
tags: []
|
tags:
|
||||||
|
- CinemachineTarget
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
- Ignore Raycast
|
- Ignore Raycast
|
||||||
-
|
- Player
|
||||||
- Water
|
- Water
|
||||||
- UI
|
- UI
|
||||||
-
|
-
|
||||||
|
|||||||
Reference in New Issue
Block a user