Add shooting rays and crosshair
This commit is contained in:
parent
7d60350142
commit
07720ef5e6
@ -133,12 +133,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6870369192359082222}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1.62, z: 0}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 4112688413114993738}
|
||||
m_Father: {fileID: 1618967478166023428}
|
||||
m_RootOrder: 3
|
||||
m_Father: {fileID: 3742571491028069048}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &4414509310837669210
|
||||
Camera:
|
||||
@ -235,7 +235,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: f6e08271c272323469510daa22c35599, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Camera: {fileID: 9173392441446035453}
|
||||
Camera: {fileID: 3742571491028069048}
|
||||
DisableInput: 0
|
||||
FullSyncFrequency: 2
|
||||
--- !u!114 &3508289943927587728
|
||||
@ -275,6 +275,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 11
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4833458671639168932, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7391558911651855222, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -330,13 +334,13 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7391558912774766599, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &1618967478166023428 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7391558912774766616, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &7808238467771803924 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2071588178488902664, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &3742571491028069048 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 4833458671639168932, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
m_PrefabInstance: {fileID: 8134536652936637724}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
@ -1,5 +1,35 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &379718841342258282
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2637233632139837434}
|
||||
m_Layer: 0
|
||||
m_Name: GunShootPoint
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2637233632139837434
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 379718841342258282}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.05, z: 0.55}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8204020546429986303}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1536982187247873486
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -31,6 +61,7 @@ Transform:
|
||||
- {fileID: 7485469696879136409}
|
||||
- {fileID: 7297658690187546150}
|
||||
- {fileID: 1308935639964380857}
|
||||
- {fileID: 2637233632139837434}
|
||||
m_Father: {fileID: 1865991757674780053}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -522,7 +553,7 @@ BoxCollider:
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 0.5, y: 1.3, z: 0.5}
|
||||
m_Size: {x: 0.7, y: 1.3, z: 0.7}
|
||||
m_Center: {x: 0, y: 0.65, z: 0}
|
||||
--- !u!1 &7391558912774766599
|
||||
GameObject:
|
||||
@ -557,6 +588,7 @@ Transform:
|
||||
- {fileID: 7391558912582364399}
|
||||
- {fileID: 7391558913662534769}
|
||||
- {fileID: 7391558912167870012}
|
||||
- {fileID: 4833458671639168932}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -616,6 +648,11 @@ MonoBehaviour:
|
||||
Body: {fileID: 7391558913662534769}
|
||||
Gun: {fileID: 1865991757674780053}
|
||||
GunBobber: {fileID: 2075495528035690810}
|
||||
CameraRoot: {fileID: 4833458671639168932}
|
||||
BulletSourcePoint: {fileID: 2637233632139837434}
|
||||
BulletHitLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 512
|
||||
Lerpables:
|
||||
- {fileID: 2566772175078312154}
|
||||
- {fileID: 1798037817325599949}
|
||||
@ -678,7 +715,7 @@ BoxCollider:
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 0.5, y: 0.5, z: 0.5}
|
||||
m_Size: {x: 0.7, y: 0.7, z: 0.7}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &7391558913662534768
|
||||
GameObject:
|
||||
@ -870,6 +907,36 @@ BoxCollider:
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &8506552293636427135
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4833458671639168932}
|
||||
m_Layer: 0
|
||||
m_Name: CameraRoot
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4833458671639168932
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8506552293636427135}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1.6, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7391558912774766616}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &8952758565847848432
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1365,7 +1365,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16548
|
||||
m_Name: pb_Mesh21336
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -3089,7 +3089,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16484
|
||||
m_Name: pb_Mesh21252
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -3789,7 +3789,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16628
|
||||
m_Name: pb_Mesh21446
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -4458,7 +4458,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16328
|
||||
m_Name: pb_Mesh21058
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -5792,7 +5792,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16598
|
||||
m_Name: pb_Mesh21416
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -7736,7 +7736,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16694
|
||||
m_Name: pb_Mesh21540
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -8414,7 +8414,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1618967478166023428, guid: e3d975a8d1b28eb4b9f646262c56653d, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
value: 0.02
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1618967478166023428, guid: e3d975a8d1b28eb4b9f646262c56653d, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
@ -11237,7 +11237,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16288
|
||||
m_Name: pb_Mesh21000
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -12743,7 +12743,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16528
|
||||
m_Name: pb_Mesh21310
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -16507,7 +16507,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16314
|
||||
m_Name: pb_Mesh21036
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -16827,7 +16827,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16576
|
||||
m_Name: pb_Mesh21364
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -17294,7 +17294,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16652
|
||||
m_Name: pb_Mesh21478
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -17550,7 +17550,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16664
|
||||
m_Name: pb_Mesh21490
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -17888,7 +17888,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16268
|
||||
m_Name: pb_Mesh20978
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@ -18052,7 +18052,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh16434
|
||||
m_Name: pb_Mesh21192
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
|
@ -49,8 +49,10 @@ namespace NeonTea.Quakeball.Players {
|
||||
|
||||
ShootAction = new InputAction("Shoot", binding: "<Mouse>/leftButton");
|
||||
ShootAction.performed += _ => {
|
||||
if (Networking.Net.Singleton.Instance != null) {
|
||||
ShootData shootData = new ShootData(Player.Pitch, Player.Yaw, Player.CreateSyncPacket());
|
||||
Networking.Net.Singleton.Instance.LocalPlayerAction(PlayerAction.Shoot, shootData);
|
||||
}
|
||||
Player.Shoot();
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,12 @@ namespace NeonTea.Quakeball.Players {
|
||||
public Transform Gun;
|
||||
public Animator GunBobber;
|
||||
|
||||
[Header("Shooting")]
|
||||
[Tooltip("For raycasting the shoot target.")]
|
||||
public Transform CameraRoot;
|
||||
public Transform BulletSourcePoint;
|
||||
public LayerMask BulletHitLayer;
|
||||
|
||||
[Header("Visuals")]
|
||||
public DesyncLerper[] Lerpables;
|
||||
|
||||
@ -135,7 +141,22 @@ namespace NeonTea.Quakeball.Players {
|
||||
}
|
||||
|
||||
public void Shoot() {
|
||||
Terminal.Singleton.Println("<color=#F00><b>BANG!</b></color>");
|
||||
Vector3 From = CameraRoot.position;
|
||||
Vector3 Direction = CameraRoot.forward;
|
||||
RaycastHit Hit;
|
||||
if (Physics.Raycast(From, Direction, out Hit)) {
|
||||
Vector3 To = Hit.point;
|
||||
Vector3 GunPoint = BulletSourcePoint.position;
|
||||
Vector3 Delta = To - GunPoint;
|
||||
if (Physics.Raycast(GunPoint, Delta, out Hit, Delta.magnitude, BulletHitLayer)) {
|
||||
Player Player = Hit.rigidbody.GetComponent<Player>();
|
||||
if (Player != null) {
|
||||
Debug.DrawLine(GunPoint, To, Color.red, 5f);
|
||||
}
|
||||
} else {
|
||||
Debug.DrawLine(GunPoint, To, Color.yellow, 5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGrounded() {
|
||||
|
8
Assets/Sprites.meta
Normal file
8
Assets/Sprites.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9cb629d803014f48b2206b875c1f76c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1
CREDITS.md
Normal file
1
CREDITS.md
Normal file
@ -0,0 +1 @@
|
||||
- [Crosshair](Assets/Sprites/Crosshair.png) by MarkieAnn Packer from the Noun Project
|
Loading…
Reference in New Issue
Block a user