Pull request #5: Soulaha

Merge in CEGJ/creative-jam-20 from Soulaha to main

* commit '872fb4de7443e0899ab649d0a67f77ecc34a7f1d':
  Fix warping  on cannon WIP Ammo types skeleton
  Add firerate and possible to hold down btn to fire
This commit is contained in:
Soulaha 2022-05-14 05:57:41 +00:00
commit 0a88803604
8 changed files with 231 additions and 86 deletions

View File

@ -24,13 +24,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675257017922} m_GameObject: {fileID: 6969840675257017922}
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.258, z: 0.522} m_LocalPosition: {x: 0, y: 0.51600003, z: 0.5}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 2, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 6969840675949508871} - {fileID: 6969840675949508871}
m_Father: {fileID: 6969840675499469969} m_Father: {fileID: 6969840675499469969}
m_RootOrder: 0 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &6969840675499469974 --- !u!1 &6969840675499469974
GameObject: GameObject:
@ -41,13 +41,11 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 6969840675499469969} - component: {fileID: 6969840675499469969}
- component: {fileID: 6969840675499469970} - component: {fileID: 3117915759359451286}
- component: {fileID: 6969840675499469971}
- component: {fileID: 6969840675499469972}
- component: {fileID: 6969840675499469973}
- component: {fileID: 6969840675499469968} - component: {fileID: 6969840675499469968}
- component: {fileID: 1832045534445164820}
m_Layer: 0 m_Layer: 0
m_Name: Turret m_Name: Player
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -62,77 +60,15 @@ Transform:
m_GameObject: {fileID: 6969840675499469974} m_GameObject: {fileID: 6969840675499469974}
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: 1, z: 0} m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 2, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 1084289763269634631}
- {fileID: 6969840675257017921} - {fileID: 6969840675257017921}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6969840675499469970 --- !u!114 &3117915759359451286
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675499469974}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &6969840675499469971
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675499469974}
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: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
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!65 &6969840675499469972
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675499469974}
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!114 &6969840675499469973
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -141,13 +77,11 @@ MonoBehaviour:
m_GameObject: {fileID: 6969840675499469974} m_GameObject: {fileID: 6969840675499469974}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a12feff9954dae440b01b5ac3c3749bd, type: 3} m_Script: {fileID: 11500000, guid: 44fc4a66977bce94dbaccf9ae1d06e2b, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
cannon: {fileID: 6969840675257017922} points: 0
projectile: {fileID: 5630905120393344806, guid: 70e77cdd333989d4193d3d85029d8cbe, type: 3} cannon: {fileID: 0}
lookDepth: 400
cannonForce: 1000
--- !u!114 &6969840675499469968 --- !u!114 &6969840675499469968
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -179,7 +113,7 @@ MonoBehaviour:
m_ActionName: Player/Move[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow] m_ActionName: Player/Move[/Keyboard/w,/Keyboard/upArrow,/Keyboard/s,/Keyboard/downArrow,/Keyboard/a,/Keyboard/leftArrow,/Keyboard/d,/Keyboard/rightArrow]
- m_PersistentCalls: - m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 6969840675499469973} - m_Target: {fileID: 1832045534445164820}
m_TargetAssemblyTypeName: CannonScript, Assembly-CSharp m_TargetAssemblyTypeName: CannonScript, Assembly-CSharp
m_MethodName: OnLook m_MethodName: OnLook
m_Mode: 0 m_Mode: 0
@ -195,7 +129,7 @@ MonoBehaviour:
m_ActionName: Player/Look[/Mouse/delta] m_ActionName: Player/Look[/Mouse/delta]
- m_PersistentCalls: - m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 6969840675499469973} - m_Target: {fileID: 1832045534445164820}
m_TargetAssemblyTypeName: CannonScript, Assembly-CSharp m_TargetAssemblyTypeName: CannonScript, Assembly-CSharp
m_MethodName: OnFire m_MethodName: OnFire
m_Mode: 0 m_Mode: 0
@ -254,6 +188,24 @@ MonoBehaviour:
m_DefaultActionMap: Player m_DefaultActionMap: Player
m_SplitScreenIndex: -1 m_SplitScreenIndex: -1
m_Camera: {fileID: 0} m_Camera: {fileID: 0}
--- !u!114 &1832045534445164820
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675499469974}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a12feff9954dae440b01b5ac3c3749bd, type: 3}
m_Name:
m_EditorClassIdentifier:
cannon: {fileID: 6969840675257017922}
projectile: {fileID: 5630905120393344806, guid: 70e77cdd333989d4193d3d85029d8cbe, type: 3}
lookDepth: 400
cannonForce: 1000
fireRate: 0.5
fireTimer: 0
--- !u!1 &6969840675949508920 --- !u!1 &6969840675949508920
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -281,7 +233,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6969840675949508920} m_GameObject: {fileID: 6969840675949508920}
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: 1.59} m_LocalPosition: {x: 0, y: 0, z: 1.5}
m_LocalScale: {x: 0.35406, y: 0.18224074, z: 3} m_LocalScale: {x: 0.35406, y: 0.18224074, z: 3}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@ -351,3 +303,100 @@ BoxCollider:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &8541489750845001500
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1084289763269634631}
- component: {fileID: 4633718394267932718}
- component: {fileID: 5887539962872066884}
- component: {fileID: 2713817942748548729}
m_Layer: 0
m_Name: Body
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1084289763269634631
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8541489750845001500}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 2, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6969840675499469969}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &4633718394267932718
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8541489750845001500}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5887539962872066884
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8541489750845001500}
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: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
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!65 &2713817942748548729
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8541489750845001500}
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}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f8f4cfd69eb82d147a0230b4a8013f1a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Ammo
{
private float cost;
abstract public void fire();
}

View File

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

View File

@ -9,7 +9,12 @@ public class CannonScript : MonoBehaviour
[SerializeField] private GameObject projectile; [SerializeField] private GameObject projectile;
[SerializeField] private float lookDepth; [SerializeField] private float lookDepth;
[SerializeField] private float cannonForce; [SerializeField] private float cannonForce;
[SerializeField] private float fireRate = 0.5f;
[SerializeField]private float fireTimer;
private bool firing = false;
private Vector3 lookDir; private Vector3 lookDir;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
@ -19,7 +24,16 @@ public class CannonScript : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(firing){
fireTimer += Time.deltaTime;
if(fireTimer >= fireRate){
GameObject proj = Instantiate(projectile, transform.position, cannon.transform.rotation);
proj.GetComponent<Rigidbody>().AddForce(cannonForce * lookDir, ForceMode.Impulse);
fireTimer = 0;
}
}else if(fireTimer < fireRate){
fireTimer += Time.deltaTime;
}
} }
private Vector3 GetMouseWorldPosition(){ private Vector3 GetMouseWorldPosition(){
@ -39,10 +53,12 @@ public class CannonScript : MonoBehaviour
} }
public void OnFire(InputAction.CallbackContext ctx){ public void OnFire(InputAction.CallbackContext ctx){
if(ctx.performed){ if(ctx.started){//btn pressed
GameObject proj = Instantiate(projectile, transform.position, cannon.transform.rotation); firing = true;
proj.GetComponent<Rigidbody>().AddForce(cannonForce * lookDir, ForceMode.Impulse); }else if(ctx.canceled){//btn released
} firing = false;
}
} }
} }

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private float points;
[SerializeField] private CannonScript cannon;
// Start is called before the first frame update
void Start()
{
points = 0;
}
// Update is called once per frame
void Update()
{
}
public float getPoints(){
return points;
}
public void setPoints(float nPoints){
points = nPoints;
}
public void spendPoints(float amount){
if(amount <= points){
points = points - amount;
}
}
public void gainPoints(float amount){
points += amount;
}
}

View File

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