mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-21 17:24:45 -05:00
Shooting work started. Needs Hit Detection Revisions
Waiting on Karl to fix major red flags before I continue this
This commit is contained in:
parent
d3811aa2f2
commit
4d43e3c832
|
|
@ -492,12 +492,9 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
range: 250
|
range: 250
|
||||||
fireRate: 4
|
fireRate: 4
|
||||||
runnerTag: Player
|
|
||||||
partToRotate: {fileID: 6313754771726110875}
|
|
||||||
rotationSpeed: 10
|
rotationSpeed: 10
|
||||||
ArrowPrefab: {fileID: 26604539265034264, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
ArrowPrefab: {fileID: 26604539265034267, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
||||||
firePoint: {fileID: 4784627841241590487}
|
firePoint: {fileID: 4784627841241590487}
|
||||||
runners: []
|
|
||||||
--- !u!114 &8721692118063281005
|
--- !u!114 &8721692118063281005
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ GameObject:
|
||||||
- component: {fileID: 26604539265034268}
|
- component: {fileID: 26604539265034268}
|
||||||
- component: {fileID: 26604539265034269}
|
- component: {fileID: 26604539265034269}
|
||||||
- component: {fileID: 26604539265034266}
|
- component: {fileID: 26604539265034266}
|
||||||
|
- component: {fileID: 2287528990630677962}
|
||||||
|
- component: {fileID: 54086400264625859}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Arrow
|
m_Name: Arrow
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -95,3 +97,68 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
speed: 35
|
speed: 35
|
||||||
|
--- !u!114 &2287528990630677962
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 26604539265034264}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
NetworkInstanceId: 0
|
||||||
|
PrefabHash: 7761068546291200244
|
||||||
|
PrefabHashGenerator: Arrow
|
||||||
|
AlwaysReplicateAsRoot: 0
|
||||||
|
DontDestroyWithOwner: 0
|
||||||
|
--- !u!114 &54086400264625859
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 26604539265034264}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
FixedSendsPerSecond: 20
|
||||||
|
AssumeSyncedSends: 1
|
||||||
|
InterpolatePosition: 1
|
||||||
|
SnapDistance: 10
|
||||||
|
InterpolateServer: 1
|
||||||
|
MinMeters: 0.15
|
||||||
|
MinDegrees: 1.5
|
||||||
|
ExtrapolatePosition: 0
|
||||||
|
MaxSendsToExtrapolate: 5
|
||||||
|
Channel:
|
||||||
|
EnableRange: 0
|
||||||
|
EnableNonProvokedResendChecks: 0
|
||||||
|
DistanceSendrate:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 20
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 500
|
||||||
|
value: 20
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,8 @@ MonoBehaviour:
|
||||||
PlayerPrefab: 0
|
PlayerPrefab: 0
|
||||||
- Prefab: {fileID: 6689294808140859937, guid: 96c2075f01b997847922f482f584a6b0, type: 3}
|
- Prefab: {fileID: 6689294808140859937, guid: 96c2075f01b997847922f482f584a6b0, type: 3}
|
||||||
PlayerPrefab: 0
|
PlayerPrefab: 0
|
||||||
|
- Prefab: {fileID: 26604539265034264, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
||||||
|
PlayerPrefab: 0
|
||||||
PlayerPrefabHash:
|
PlayerPrefabHash:
|
||||||
id: 0
|
id: 0
|
||||||
CreatePlayerPrefab: 0
|
CreatePlayerPrefab: 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using MLAPI;
|
using MLAPI;
|
||||||
|
using MLAPI.Messaging;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -20,9 +21,11 @@ public class Archer : NetworkBehaviour
|
||||||
[Header("Unity Setup Fields")]
|
[Header("Unity Setup Fields")]
|
||||||
public float rotationSpeed = 10f;
|
public float rotationSpeed = 10f;
|
||||||
|
|
||||||
public GameObject ArrowPrefab;
|
public Transform ArrowPrefab;
|
||||||
public Transform firePoint;
|
public Transform firePoint;
|
||||||
|
|
||||||
|
private GameObject arrowInScene;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
||||||
// Only the host should update targetting
|
// Only the host should update targetting
|
||||||
|
|
@ -85,27 +88,27 @@ public class Archer : NetworkBehaviour
|
||||||
this.gameObject.transform.rotation = Quaternion.Euler (0f, rotation.y, 0f);
|
this.gameObject.transform.rotation = Quaternion.Euler (0f, rotation.y, 0f);
|
||||||
|
|
||||||
// Actually shoot it
|
// Actually shoot it
|
||||||
// TODO: Network this part
|
|
||||||
/*
|
if (shootingCooldown <= 0f) {
|
||||||
if (shootingCooldown <= 0f)
|
ShootArrowServerRPC();
|
||||||
{
|
|
||||||
Shoot();
|
|
||||||
shootingCooldown = 1f/ fireRate;
|
shootingCooldown = 1f/ fireRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
shootingCooldown -= Time.deltaTime;
|
shootingCooldown -= Time.deltaTime;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ServerRpc(RequireOwnership = false)]
|
||||||
void Shoot() {
|
private void ShootArrowServerRPC() {
|
||||||
|
arrowInScene = Instantiate(ArrowPrefab, firePoint.position, firePoint.rotation).gameObject;
|
||||||
|
arrowInScene.GetComponent<NetworkObject>().Spawn(null, true);
|
||||||
|
arrowInScene.GetComponent<Arrow>().Seek(target.position);
|
||||||
|
/*
|
||||||
GameObject arrowGO = Instantiate(ArrowPrefab, firePoint.position, firePoint.rotation).gameObject;
|
GameObject arrowGO = Instantiate(ArrowPrefab, firePoint.position, firePoint.rotation).gameObject;
|
||||||
Arrow arrow = arrowGO.GetComponent<Arrow>();
|
Arrow arrow = arrowGO.GetComponent<Arrow>();
|
||||||
|
|
||||||
if (arrow != null) {
|
if (arrow != null) {
|
||||||
arrow.Seek(target.position);
|
arrow.Seek(target.position);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
using System.Numerics;
|
using MLAPI;
|
||||||
using System.Runtime.CompilerServices;
|
using MLAPI.Messaging;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Arrow : MonoBehaviour
|
public class Arrow : NetworkBehaviour {
|
||||||
{
|
private Vector3 target;
|
||||||
private UnityEngine.Vector3 target;
|
private bool isLive = false;
|
||||||
private bool isLive=false;
|
|
||||||
|
|
||||||
public float speed = 90f;
|
public float speed = 90f;
|
||||||
|
|
||||||
//finds targed
|
//finds targed
|
||||||
public void Seek(UnityEngine.Vector3 _target)
|
public void Seek(UnityEngine.Vector3 _target) {
|
||||||
{
|
|
||||||
//can also do effects, speed on the bullet, damage amount, etc.
|
//can also do effects, speed on the bullet, damage amount, etc.
|
||||||
target = _target;
|
target = _target;
|
||||||
isLive = true;
|
isLive = true;
|
||||||
|
|
@ -20,23 +18,25 @@ public class Arrow : MonoBehaviour
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (target == null)
|
// Only move the arrow on the host
|
||||||
{
|
if (!IsHost) { return; }
|
||||||
//Destroy(gameObject);
|
|
||||||
return;
|
// This keeps the static arrows from moving without a target
|
||||||
}
|
if (target == null) { return; }
|
||||||
if (isLive)
|
|
||||||
{
|
// The arrow is allowed to move towards a target
|
||||||
UnityEngine.Vector3 dir = target - transform.position;
|
if (isLive) {
|
||||||
|
// Find the direction to fire in
|
||||||
|
Vector3 dir = target - transform.position;
|
||||||
|
|
||||||
//distance
|
// Calculate distance
|
||||||
float distanceThisFrame = speed * Time.deltaTime;
|
float distanceThisFrame = speed * Time.deltaTime;
|
||||||
|
|
||||||
|
|
||||||
//checking from current distance to current target
|
// Checking from current distance to current target
|
||||||
if (dir.magnitude <= distanceThisFrame)
|
if (dir.magnitude <= distanceThisFrame) {
|
||||||
{
|
// NOT SURE IF THIS CALC ^ WORKS AS INTENDED
|
||||||
HitTarget();
|
HitTargetServerRPC();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,14 +46,15 @@ public class Arrow : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//logic for hitting something
|
// Arrow has connected with something
|
||||||
void HitTarget()
|
[ServerRpc]
|
||||||
{
|
private void HitTargetServerRPC() {
|
||||||
isLive=false;
|
isLive = false;
|
||||||
Destroy(gameObject);
|
|
||||||
|
// Do the hit logic
|
||||||
|
|
||||||
|
// Despawn the arrow
|
||||||
|
this.gameObject.GetComponent<NetworkObject>().Despawn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"com.unity.2d.sprite": "1.0.0",
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.collab-proxy": "1.9.0",
|
"com.unity.collab-proxy": "1.9.0",
|
||||||
"com.unity.ide.rider": "2.0.7",
|
"com.unity.ide.rider": "2.0.7",
|
||||||
"com.unity.ide.visualstudio": "2.0.12",
|
"com.unity.ide.visualstudio": "2.0.14",
|
||||||
"com.unity.ide.vscode": "1.2.4",
|
"com.unity.ide.vscode": "1.2.4",
|
||||||
"com.unity.multiplayer.mlapi": "https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi.git?path=/com.unity.multiplayer.mlapi#release/0.1.0",
|
"com.unity.multiplayer.mlapi": "https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi.git?path=/com.unity.multiplayer.mlapi#release/0.1.0",
|
||||||
"com.unity.terrain-tools": "3.0.2-preview.3",
|
"com.unity.terrain-tools": "3.0.2-preview.3",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.visualstudio": {
|
"com.unity.ide.visualstudio": {
|
||||||
"version": "2.0.12",
|
"version": "2.0.14",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user