Hello There, I Am Currently Following A Tutorial On How To Make A Multiplayer Game In Unity Using Photon.
When I Try And Shoot At The Player, I Get This Error Message
Here Is The Code For SingleShotCode.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SingleShotGun : Gun
{
[SerializeField] Camera cam;
public override void Use()
{
Shoot();
}
void Shoot()
{
Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f));
ray.origin = cam.transform.position;
if (Physics.Raycast(ray, out RaycastHit hit))
{
hit.collider.gameObject.GetComponent<IDamageable>().TakeDamage(((GunInfo)itemInfo).damage);
}
}
}
https://cdn.discordapp.com/attachments/1153029763657633903/1153029763812819014/image.png