Skip to content

fix: arrow ClientRpc error #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ public class ClientProjectileVisualization : NetworkBehaviour
{
[SerializeField]
[Tooltip("Explosion prefab used when projectile hits enemy. This should have a fixed duration.")]
private SpecialFXGraphic m_OnHitParticlePrefab;
SpecialFXGraphic m_OnHitParticlePrefab;

[SerializeField]
TrailRenderer m_TrailRenderer;

NetworkProjectileState m_NetState;

Expand All @@ -25,6 +28,8 @@ public override void OnNetworkSpawn()
return;
}

m_TrailRenderer.Clear();

m_Parent = transform.parent;
transform.parent = null;
m_NetState = m_Parent.GetComponent<NetworkProjectileState>();
Expand All @@ -36,6 +41,8 @@ public override void OnNetworkSpawn()

public override void OnNetworkDespawn()
{
m_TrailRenderer.Clear();

if (m_NetState != null)
{
transform.parent = m_Parent;
Expand Down Expand Up @@ -69,7 +76,7 @@ void Update()
}
}

private void OnEnemyHit(ulong enemyId)
void OnEnemyHit(ulong enemyId)
{
//in the future we could do quite fancy things, like deparenting the Graphics Arrow and parenting it to the target.
//For the moment we play some particles (optionally), and cause the target to animate a hit-react.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,22 @@ public override void OnNetworkSpawn()

private void FixedUpdate()
{
if (!m_Started) { return; } //don't do anything before OnNetworkSpawn has run.

Vector3 displacement = transform.forward * (m_ProjectileInfo.Speed_m_s * Time.fixedDeltaTime);
transform.position += displacement;
if (!m_Started)
{
return; //don't do anything before OnNetworkSpawn has run.
}

if (m_DestroyAtSec < Time.fixedTime)
{
// Time to return to the pool from whence it came.
NetworkObject networkObject = gameObject.GetComponent<NetworkObject>();
var networkObject = gameObject.GetComponent<NetworkObject>();
networkObject.Despawn();
return;
}

var displacement = transform.forward * (m_ProjectileInfo.Speed_m_s * Time.fixedDeltaTime);
transform.position += displacement;

if (!m_IsDead)
{
DetectCollisions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3325143161705299546
Transform:
Expand Down Expand Up @@ -96,6 +96,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_OnHitParticlePrefab: {fileID: 0}
m_TrailRenderer: {fileID: 939547987977570762}
--- !u!1001 &8427704294362486480
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -162,3 +163,8 @@ Transform:
m_CorrespondingSourceObject: {fileID: 9112595075296351182, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 8427704294362486480}
m_PrefabAsset: {fileID: 0}
--- !u!96 &939547987977570762 stripped
TrailRenderer:
m_CorrespondingSourceObject: {fileID: 8790122182988832538, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 8427704294362486480}
m_PrefabAsset: {fileID: 0}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3325143161705299546
Transform:
Expand Down Expand Up @@ -96,6 +96,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_OnHitParticlePrefab: {fileID: 8618909711417914730, guid: dc9de50a71cc1854586afa8a275a6a6b, type: 3}
m_TrailRenderer: {fileID: 4385405951865464679}
--- !u!1001 &4981226344026716285
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -166,3 +167,8 @@ Transform:
m_CorrespondingSourceObject: {fileID: 9112595075296351182, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}
--- !u!96 &4385405951865464679 stripped
TrailRenderer:
m_CorrespondingSourceObject: {fileID: 8790122182988832538, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3325143161705299546
Transform:
Expand Down Expand Up @@ -96,6 +96,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_OnHitParticlePrefab: {fileID: -6745866273066112404, guid: ae64395b058ab5e4db24271fb6fadb93, type: 3}
m_TrailRenderer: {fileID: 4385405951379145903}
--- !u!1001 &4981226344026716285
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -170,3 +171,8 @@ Transform:
m_CorrespondingSourceObject: {fileID: 9112595075296351182, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}
--- !u!96 &4385405951379145903 stripped
TrailRenderer:
m_CorrespondingSourceObject: {fileID: 8790122182468517074, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3325143161705299546
Transform:
Expand Down Expand Up @@ -96,6 +96,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_OnHitParticlePrefab: {fileID: 4562743285343113751, guid: 274d5f31ee594904399cb65bae8ec339, type: 3}
m_TrailRenderer: {fileID: 4385405950053795736}
--- !u!1001 &4981226344026716285
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -174,3 +175,8 @@ Transform:
m_CorrespondingSourceObject: {fileID: 9112595075296351182, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}
--- !u!96 &4385405950053795736 stripped
TrailRenderer:
m_CorrespondingSourceObject: {fileID: 8790122183726792677, guid: 660b64eb444497d41af2c727909eb671, type: 3}
m_PrefabInstance: {fileID: 4981226344026716285}
m_PrefabAsset: {fileID: 0}