Brackeys / MultiplayerFPS-Tutorial

A video series on making a multiplayer first-person shooter in Unity.
The Unlicense
654 stars 287 forks source link

Episode 13 27 minutes in: NullReferenceException #21

Closed IpanTheWrongWay closed 6 years ago

IpanTheWrongWay commented 6 years ago

On the PlayerShoot Script on line 64 (at the time of this video in the series) I am receiving a NullReferenceException: Object reference not set to an instance of an object PlayerShoot.RpcDoShootEffects () (at Assets/Scripts/PlayerShoot.cs:64)

I followed the video as closely as I could, even rewatching this portion 4 times. I could not find this exact issue for anyone else. Is this because I am using Unity Version 2017.1.1f1 and the syntax has changed?

Some info which may help: Clearing the Console errors and playing as stand alone in "Playe Mode" does not populate the error. When I build the game and connect them (1 host 1 client) the error only populates when the client fires. Additionally, not sure if this is the same issue or a separate one, but I am unable to see the muzzle flash of either player on the opposite screen. (As in my host cannot see client muzzle flash and vice versa) [ClientRpc] void RpcDoShootEffects() {//Problem is below this line weaponHolder.GetCurrentGraphics().muzzleFlash.Play(); }

I have been stuck on this for several hours so anyone who could explain my issue to me would be greatly appreciated.

cesarchamorro commented 6 years ago

Hello man, I'm so sorry about you're having this issue, but let's try to fix it!

Well, I think that the main issue you're having is that you have this:

weaponHolder.GetCurrentGraphics().muzzleFlash.Play();

instead of this

weaponManager.GetCurrentGraphics().muzzleFlash.Play();

try to change them and try to play, if you're not usging the source code and you're building the game by yourself try to download the PlayerShoot script, and check it out with your code.

Let me know if this answer helped you to fix your issue.

IpanTheWrongWay commented 6 years ago

Thank you, I fixed that and moved on with the project, although I was trying to add too much of my own personal stuff while watching him go.

cesarchamorro commented 6 years ago

I'm so happy, you fixed it. If you have any other issue I would be more than happy to help you 👍

nitinsingh27 commented 6 years ago

How Can we Add more Maps And Can Select them before creating the match I tried using Server Change Scene But it dosn,t work!!!!!!!!!!

cesarchamorro commented 6 years ago

Hey man, well I guess this is what you're looking for:

https://answers.unity.com/questions/871779/change-level-over-network-whats-the-correct-way.html