I made a rocket launcher that uses projectiles rather than raycast since raycast is instant etc
but when I try to send values of damage to the main player again it always gives me the warning doesnt have authority heres idk if their is a correct way of doing this and if so let me know
// on player object with authority
public void SendDamge(string name, float Splashdamage) {
CmdPlayerShot(name, Splashdamage);
}
[Command]
public void CmdPlayerShot(string _playerID, float _damage)
{
UnityEngine.Debug.Log(_playerID + " has been shot");
Player _player = GameManager1.GetPlayer(_playerID);
_player.RpcTakeDamage(_damage);
}
// on rocket without authority projectile that is instantiated from the player
public class RocketProj : Rocket
{
public bool hitPlayer;
private Vector3 midScreen;
private void OnCollisionEnter(Collision collision)
{
Debug.Log("test");
var tempexpEffect = Instantiate(explosionEffect, this.transform.position, this.transform.rotation);
Destroy(tempexpEffect, 1);
if (collision.collider.tag == "Player")
{
hitPlayer = true;
}
else hitPlayer = false;
//Destroy(this.gameObject);
}
public void hitPlayerCalcSplash(RaycastHit _hitInfo)
{
if (hitPlayer == true) {
Debug.Log(_hitInfo.collider.name);
hitColliders = Physics.OverlapSphere(_hitInfo.point, splashRadius);
int i = 0;
while (i < hitColliders.Length)
{
if (hitColliders*.tag == "Player")*
{
proximity = (_hitInfo.point - _hitInfo.collider.transform.position).magnitude;
Splashdamage = CritHitDamage - (proximity / splashRadius);
UnityEngine.Debug.Log(“Rocket Splash hit a player”);
// SendDamge(hitColliders*.name, Splashdamage);*
Destroy(this.gameObject);
}
} i++;
}
}
}