Top-down and ShootableWeapon

Help, what could be the problem. On the client, he holds the rifle straight when shooting, on other vehicles the rifle looks at the floor, the head looks at the floor. Perhaps this is due to LookDirection.
 

Attachments

  • 123.png
    123.png
    147.4 KB · Views: 5
Hello. I tried adventure mode. A copy of the deleted character is looking at the floor. The green beam is Look Ray.

In the ShootableWeapon script, I changed the direction of fire, from firePoint to the point where the player's cursor is. Maybe it's related somehow.

1645690505720.png
1645690614906.png
 
If you place a breakpoint within the PunLookSource is it sending the correct look direction?
 
Yes - you'll want to start to debug from there to determine why the wrong direction is being retrieved. It should be using the same direction as the local player.
 
I found the reason:

var lookDirection = m_LookSource.LookDirection(false);

1646149908536.png

C#:
/// <summary>
/// Returns the direction that the character is looking.
/// </summary>
/// <param name="characterLookDirection">Is the character look direction being retrieved?</param>
/// <returns>The direction that the character is looking.</returns>
public virtual Vector3 LookDirection(bool characterLookDirection) { return m_Transform.forward; }

This method returns the forward of the camera, and since I have top down, it does not suit me. I am using CinemachineViewType. I'll try to override the method.
 
Last edited:
It works now.
1646157454163.png

There was a bug with projectiles during spawn, but this is not the topic.

Error:
ArgumentException: An item with the same key has already been added. Key: PunAssaultRifleProjectile(Clone) (UnityEngine.GameObject)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <44afb4564e9347cf99a1865351ea8f4a>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <44afb4564e9347cf99a1865351ea8f4a>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.PunObjectPool.NetworkSpawnInternal (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/PunObjectPool.cs:119)
Opsive.UltimateCharacterController.Networking.Game.NetworkObjectPool.NetworkSpawn (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Opsive/UltimateCharacterController/Scripts/Networking/NetworkObjectPool.cs:53)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.ProjectileFire (System.Single strength) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:872)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Fire (System.Single strength) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:779)
_Game.Infrastructure.CodeBase.PhotonPun.PunCharacterCustom.FireRPC (System.Int32 slotID, System.Int32 actionID, System.Single strength) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/_Game/Infrastructure/CodeBase/PhotonPun/PunCharacterCustom.cs:571)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <44afb4564e9347cf99a1865351ea8f4a>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <44afb4564e9347cf99a1865351ea8f4a>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <44afb4564e9347cf99a1865351ea8f4a>:0)
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:553)
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2201)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3353)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:899)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:565)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771)
Photon.Pun.PhotonHandler.Dispatch () (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:222)
Rethrow as AggregateException: Caught 1 exception(s) in methods called by DispatchIncomingCommands(). Rethrowing first only (see above).
Photon.Pun.PhotonHandler.Dispatch () (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:240)
Photon.Pun.PhotonHandler.FixedUpdate () (at D:/MyProjects/MyGitHUB/Playzzy/Top-Down-Coop/Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:145)
 
Top