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:
|
||||
range: 250
|
||||
fireRate: 4
|
||||
runnerTag: Player
|
||||
partToRotate: {fileID: 6313754771726110875}
|
||||
rotationSpeed: 10
|
||||
ArrowPrefab: {fileID: 26604539265034264, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
||||
ArrowPrefab: {fileID: 26604539265034267, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
||||
firePoint: {fileID: 4784627841241590487}
|
||||
runners: []
|
||||
--- !u!114 &8721692118063281005
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ GameObject:
|
|||
- component: {fileID: 26604539265034268}
|
||||
- component: {fileID: 26604539265034269}
|
||||
- component: {fileID: 26604539265034266}
|
||||
- component: {fileID: 2287528990630677962}
|
||||
- component: {fileID: 54086400264625859}
|
||||
m_Layer: 0
|
||||
m_Name: Arrow
|
||||
m_TagString: Untagged
|
||||
|
|
@ -95,3 +97,68 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
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
|
||||
- Prefab: {fileID: 6689294808140859937, guid: 96c2075f01b997847922f482f584a6b0, type: 3}
|
||||
PlayerPrefab: 0
|
||||
- Prefab: {fileID: 26604539265034264, guid: 0e61ec06fdabb014bb1868596534f8b7, type: 3}
|
||||
PlayerPrefab: 0
|
||||
PlayerPrefabHash:
|
||||
id: 0
|
||||
CreatePlayerPrefab: 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using MLAPI;
|
||||
using MLAPI.Messaging;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
|
@ -20,9 +21,11 @@ public class Archer : NetworkBehaviour
|
|||
[Header("Unity Setup Fields")]
|
||||
public float rotationSpeed = 10f;
|
||||
|
||||
public GameObject ArrowPrefab;
|
||||
public Transform ArrowPrefab;
|
||||
public Transform firePoint;
|
||||
|
||||
private GameObject arrowInScene;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
// Only the host should update targetting
|
||||
|
|
@ -85,27 +88,27 @@ public class Archer : NetworkBehaviour
|
|||
this.gameObject.transform.rotation = Quaternion.Euler (0f, rotation.y, 0f);
|
||||
|
||||
// Actually shoot it
|
||||
// TODO: Network this part
|
||||
/*
|
||||
if (shootingCooldown <= 0f)
|
||||
{
|
||||
Shoot();
|
||||
|
||||
if (shootingCooldown <= 0f) {
|
||||
ShootArrowServerRPC();
|
||||
shootingCooldown = 1f/ fireRate;
|
||||
}
|
||||
|
||||
shootingCooldown -= Time.deltaTime;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void Shoot() {
|
||||
|
||||
[ServerRpc(RequireOwnership = false)]
|
||||
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;
|
||||
Arrow arrow = arrowGO.GetComponent<Arrow>();
|
||||
|
||||
if (arrow != null) {
|
||||
arrow.Seek(target.position);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using MLAPI;
|
||||
using MLAPI.Messaging;
|
||||
using UnityEngine;
|
||||
|
||||
public class Arrow : MonoBehaviour
|
||||
{
|
||||
private UnityEngine.Vector3 target;
|
||||
private bool isLive=false;
|
||||
public class Arrow : NetworkBehaviour {
|
||||
private Vector3 target;
|
||||
private bool isLive = false;
|
||||
|
||||
public float speed = 90f;
|
||||
|
||||
//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.
|
||||
target = _target;
|
||||
isLive = true;
|
||||
|
|
@ -20,23 +18,25 @@ public class Arrow : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
//Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
if (isLive)
|
||||
{
|
||||
UnityEngine.Vector3 dir = target - transform.position;
|
||||
// Only move the arrow on the host
|
||||
if (!IsHost) { return; }
|
||||
|
||||
//distance
|
||||
// This keeps the static arrows from moving without a target
|
||||
if (target == null) { return; }
|
||||
|
||||
// The arrow is allowed to move towards a target
|
||||
if (isLive) {
|
||||
// Find the direction to fire in
|
||||
Vector3 dir = target - transform.position;
|
||||
|
||||
// Calculate distance
|
||||
float distanceThisFrame = speed * Time.deltaTime;
|
||||
|
||||
|
||||
//checking from current distance to current target
|
||||
if (dir.magnitude <= distanceThisFrame)
|
||||
{
|
||||
HitTarget();
|
||||
// Checking from current distance to current target
|
||||
if (dir.magnitude <= distanceThisFrame) {
|
||||
// NOT SURE IF THIS CALC ^ WORKS AS INTENDED
|
||||
HitTargetServerRPC();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -46,14 +46,15 @@ public class Arrow : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
//logic for hitting something
|
||||
void HitTarget()
|
||||
{
|
||||
isLive=false;
|
||||
Destroy(gameObject);
|
||||
// Arrow has connected with something
|
||||
[ServerRpc]
|
||||
private void HitTargetServerRPC() {
|
||||
isLive = false;
|
||||
|
||||
// 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.collab-proxy": "1.9.0",
|
||||
"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.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",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.12",
|
||||
"version": "2.0.14",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user