multiplayer game other player setactive false
(Sorry my English is bad)[I use PUN2 for server] My codes:
Player:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Realtime; using Photon.Pun; using TMPro; using UnityEngine.UI;
namespace Com.Kawaiisun.SimpleHostile { public class multiplayerc : MonoBehaviourPunCallbacks { public GameObject mesh; public Transform spawnPos; public Transform spawnPoskalkan; public Transform spawnPosportal1; public Transform spawnPosaura; public GameObject sp0; public GameObject sp1; public GameObject sp2; public GameObject sp3; public GameObject sp4; public GameObject sp5; public GameObject sp6; public GameObject sp7; public GameObject sp8; public GameObject sp9; public int canmax=100; private Transform ui_healthbar; public int manamax = 100; private Transform ui_manabar; public float attackDamage=5; public float attackRange=3; public float attackCoolDown=1; private Manager manager; public TextMeshPro playerUsername; private Text ui_username; private multiplayerc pc; private float attackTimer; public bool lockCursor; public float mouseSensitivity = 10; public Vector2 pitchMinMax = new Vector2(-40, 85); public float rotationSmoothTime = 0.1f; [HideInInspector] public ProfileData playerProfile;
public float speedH = 2.0f;
public float speedV = 2.0f;
Camera cam;
public float yaw;
public float pitch;
float smoothYaw;
float smoothPitch;
float yawSmoothV;
float pitchSmoothV;
float verticalVelocity;
Vector3 velocity;
Vector3 smoothV;
Vector3 rotationSmoothVelocity;
Vector3 currentRotation;
bool jumping;
float lastGroundedTime;
bool disabled;
//public Transform spawnPos;
//public Transform spawnPoskalkan;
//public Transform spawnPosportal1;
//public Transform spawnPosaura;
//public GameObject sp0;
//public GameObject sp1;
//public GameObject sp2;
//public GameObject sp3;
//public GameObject sp4;
//public GameObject sp5;
//public GameObject sp6;
//public GameObject sp7;
//public GameObject sp8;
//public GameObject sp9;
//public Image gmbar;
public Animator anim;
public PhotonView pw;
public float zaman = 0;
public bool durmak = true;
public bool saldırı = false;
public bool hareket = false;
public bool hızlıhareket = false;
public float hiz = 7.5f, yercekimi = 10f, yorgunluk = 0f;
public bool dc;
public bool uzunsaldırı = false;
Rigidbody rd;
public float can = 100;
private Text cantext;
public float mana = 100;
private Text manatext;
[PunRPC]
private void Start()
{
gameObject.SetActive(pw.IsMine);
canmax = 100;
manamax = 100;
manager = GameObject.Find("Manager").GetComponent<Manager>();
pc = GetComponent<multiplayerc>();
cam = Camera.main;
if (lockCursor)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
yaw = transform.eulerAngles.y;
//pitch = cam.transform.localEulerAngles.x;
smoothYaw = yaw;
smoothPitch = pitch;
pw = GetComponent<PhotonView>();
if (pw.IsMine == true)
{
pw.RPC("SyncProfile", RpcTarget.All, Launcher.myProfile.username, Launcher.myProfile.level, Launcher.myProfile.xp);
gameObject.layer = 11;
ChangeLayerRecursively(mesh.transform, 11);
gameObject.tag = ("Player");
cantext = GameObject.Find("HUD/Health/Can").GetComponent<Text>();
manatext = GameObject.Find("HUD/Fuel/Mana").GetComponent<Text>();
ui_healthbar = GameObject.Find("HUD/Health/Bar").transform;
ui_manabar = GameObject.Find("HUD/Fuel/Bar").transform;
RefreshHealthBar();
ui_username = GameObject.Find("HUD/Username/Text").GetComponent<Text>();
ui_username.text = Launcher.myProfile.username;
playerUsername.text = Launcher.myProfile.username;
uzunsaldırı = false;
durmak = true;
dc = true;
hareket = false;
saldırı = false;
hızlıhareket = false;
anim = GetComponent<Animator>();
rd = GetComponent<Rigidbody>();
//GetComponent<Renderer>().material.color = Color.red;
//gmbar.GetComponent<Image>().color = new Color32(191, 255, 97, 100);
}
}
private void ChangeLayerRecursively(Transform p_trans, int p_layer)
{
p_trans.gameObject.layer = p_layer;
foreach (Transform t in p_trans) ChangeLayerRecursively(t, p_layer);
}
[PunRPC]
void Update()
{
if (!pw.IsMine) return;
if (pw.IsMine == true)
{
Multi_Update();
RefreshHealthBar();
}
}
void RefreshHealthBar()
{
float t_health_ratio = (float)can / (float)canmax;
ui_healthbar.localScale = Vector3.Lerp(ui_healthbar.localScale, new Vector3(t_health_ratio, 1, 1), Time.deltaTime * 8f);
float t_mana_ratio = (float)mana / (float)manamax;
ui_manabar.localScale = Vector3.Lerp(ui_manabar.localScale, new Vector3(t_mana_ratio, 1, 1), Time.deltaTime * 8f);
}
[PunRPC]
private void DoAttack()
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit t_hit;
if (Physics.Raycast(ray, out t_hit, attackRange))
{
if (t_hit.collider.gameObject.layer == 11)
{
//give damage
t_hit.collider.transform.root.gameObject.GetPhotonView().RPC("TakeDamage", RpcTarget.All, attackDamage, PhotonNetwork.LocalPlayer.ActorNumber);
//check for kill
//if (t_hit.collider.transform.root.gameObject.GetComponent<Player>().CheckKill(loadout[currentIndex].damage))
//{
// manager.ChangeStat_S(PhotonNetwork.LocalPlayer.ActorNumber, 0, 1);
//}
//show hitmarker
attackRange = 1f;
}
}
}
public void TakeDamage(int p_damage, int p_actor)
{
if (pw.IsMine)
{
can -= p_damage;
//RefreshHealthBar();
if (can <= 0)
{
manager.Spawn();
manager.ChangeStat_S(PhotonNetwork.LocalPlayer.ActorNumber, 1, 1);
if (p_actor >= 0)
manager.ChangeStat_S(p_actor, 0, 1);
PhotonNetwork.Destroy(gameObject);
}
}
}
[PunRPC]
public void Multi_Update()
{
attackTimer += Time.deltaTime;
if (pc.dc == true)
{
if (Input.GetMouseButtonUp(0) && attackTimer >= attackCoolDown)
{
pc.dc = false;
attackTimer = 0f;
DoAttack();
}
}
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
if (disabled)
{
return;
}
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
Vector3 inputDir = new Vector3(input.x, 0, input.y).normalized;
Vector3 worldInputDir = transform.TransformDirection(inputDir);
float mX = Input.GetAxisRaw("Mouse X");
float mY = Input.GetAxisRaw("Mouse Y");
float mMag = Mathf.Sqrt(mX * mX + mY * mY);
if (mMag > 5)
{
mX = 0;
mY = 0;
}
yaw += mX * mouseSensitivity;
pitch -= mY * mouseSensitivity;
pitch = Mathf.Clamp(pitch, pitchMinMax.x, pitchMinMax.y);
smoothPitch = Mathf.SmoothDampAngle(smoothPitch, pitch, ref pitchSmoothV, rotationSmoothTime);
smoothYaw = Mathf.SmoothDampAngle(smoothYaw, yaw, ref yawSmoothV, rotationSmoothTime);
transform.eulerAngles = Vector3.up * smoothYaw;
if (mana >= 10)
{
if (Input.GetKeyDown(KeyCode.Alpha3))
{
Instantiate(sp3, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha4))
{
Instantiate(sp4, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha5))
{
Instantiate(sp5, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha6))
{
Instantiate(sp6, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha7))
{
Instantiate(sp7, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad3))
{
Instantiate(sp3, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad4))
{
Instantiate(sp4, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad5))
{
Instantiate(sp5, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad6))
{
Instantiate(sp6, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad7))
{
Instantiate(sp7, spawnPos.position, spawnPos.rotation);
mana -= 10;
}
}
if (zaman >= -10f)
{
durmak = true;
dc = true;
saldırı = false;
uzunsaldırı = false;
hareket = false;
hızlıhareket = false;
anim.SetBool("attack_long_001", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward", false);
anim.SetBool("move_forward_fast", false);
anim.SetBool("idle_normal", true);
}
if (zaman <= 0)
{
zaman += 5f * Time.deltaTime;
}
if (zaman <= -25f)
{
zaman = -25f;
}
if (dc == true)
{
if (Input.GetMouseButtonDown(0))
{
print(1);
zaman -= 75f * Time.deltaTime * 100f * 4f;
saldırı = true;
uzunsaldırı = false;
hareket = false;
hızlıhareket = false;
durmak = false;
anim.SetBool("attack_long_001", false);
anim.SetBool("attack_short_001", true);
anim.SetBool("move_forward", false);
anim.SetBool("move_forward_fast", false);
anim.SetBool("idle_normal", false);
}
}
if (dc == true)
{
if (Input.GetMouseButtonDown(1))
{
print(2);
zaman -= 75f * Time.deltaTime * 100f * 4f;
saldırı = false;
uzunsaldırı = true;
hareket = false;
hızlıhareket = false;
durmak = false;
dc = false;
anim.SetBool("attack_short_001", false);
anim.SetBool("attack_long_001", true);
anim.SetBool("move_forward", false);
anim.SetBool("move_forward_fast", false);
anim.SetBool("idle_normal", false);
// Invoke("PlayAudioClip",1f);
}
}
//if (isgrounded == true){
if (Input.GetKey(KeyCode.Space))
{
transform.Translate(0, 5f * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.LeftControl))
{
transform.Translate(0, -5f * Time.deltaTime, 0);
}
if (durmak == true)
{
yorgunluk -= 5f * Time.deltaTime;
anim.SetBool("attack_long_001", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward", false);
anim.SetBool("move_forward_fast", false);
anim.SetBool("idle_normal", true);
}
if (Input.GetKey(KeyCode.A))
{
//transform.Rotate (0, -2.5f, 0);
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("attack_long_001", false);
anim.SetBool("move_forward", true);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(-1 * Time.deltaTime * hiz, 0, 0);
print("at");
}
if (Input.GetKey(KeyCode.D))
{
//transform.Rotate (0, 2.5f, 0);
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(1 * Time.deltaTime * hiz, 0, 0);
print("at");
}
if (Input.GetKey(KeyCode.W))
{
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(0, 0, 1 * Time.deltaTime * hiz);
print("at");
}
if (Input.GetKey(KeyCode.S))
{
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(0, 0, -1 * Time.deltaTime * hiz);
print("at");
}
if (Input.GetKey(KeyCode.RightArrow))
{
zaman -= 75f * Time.deltaTime * 4f;
//transform.Rotate(0, 2.5f, 0);
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(1 * Time.deltaTime * hiz, 0, 0);
print("at");
}
if (Input.GetKey(KeyCode.LeftArrow))
{
//transform.Rotate(0, -2.5f, 0);
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(-1 * Time.deltaTime * hiz, 0, 0);
print("at");
}
if (Input.GetKey(KeyCode.UpArrow))
{
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(0, 0, 1 * Time.deltaTime * hiz);
print("at");
}
if (Input.GetKey(KeyCode.DownArrow))
{
zaman -= 75f * Time.deltaTime * 4f;
anim.SetBool("move_forward", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
anim.SetBool("move_forward_fast", false);
uzunsaldırı = false;
saldırı = false;
hareket = true;
hızlıhareket = false;
durmak = false;
dc = false;
transform.Translate(0, 0, -1 * Time.deltaTime * hiz);
print("at");
}
if (yorgunluk <= 0)
{
yorgunluk = 0;
}
if (yorgunluk >= 0)
{
yorgunluk -= 2.5f * Time.deltaTime;
}
if (Input.GetKey(KeyCode.LeftShift))
{
zaman -= 75f * Time.deltaTime * 4f;
uzunsaldırı = false;
saldırı = false;
hareket = false;
hızlıhareket = true;
durmak = false;
dc = false;
anim.SetBool("move_forward_fast", true);
anim.SetBool("attack_long_001", false);
anim.SetBool("move_forward", false);
anim.SetBool("idle_normal", false);
anim.SetBool("attack_short_001", false);
yorgunluk += 10f * Time.deltaTime;
hiz = 10f;
}
else
{
hiz = 7.5f;
}
if (yorgunluk >= 100)
{
yorgunluk = 100;
hiz = 7.5f;
if (hızlıhareket == true)
{
if (hareket == true)
{
anim.SetBool("move_forward_fast", false);
anim.SetBool("move_forward", true);
}
}
}
//aclik -= 0.67f * Time.deltaTime;
if (can >= 100)
{
can = 100;
}
if (can <= 0)
{
//Respawn();
//can -= Time.deltaTime * 5;
}
if (can > 0 && can <= 50)
{
can += Time.deltaTime * 1.1f;
}
if (can > 0 && can <= 100)
{
can += Time.deltaTime * 0.75f;
}
if (mana <= 50)
{
mana += Time.deltaTime * 1.1f;
}
if (mana <= 0)
{
mana = 0;
}
if (mana <= 100)
{
mana += Time.deltaTime * 0.75f;
}
cantext.text = "Health: " + can.ToString("f0");
manatext.text = "Mana: " + mana.ToString("f0");
}
[PunRPC]
private void SyncProfile(string p_username, int p_level, int p_xp)
{
playerProfile = new ProfileData(p_username, p_level, p_xp);
playerUsername.text = playerProfile.username;
}
}
}
Character Select:
using System.Collections; using System.Collections.Generic; using UnityEngine.SceneManagement; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI;
namespace Com.Kawaiisun.SimpleHostile { public class Karakter_multi : MonoBehaviourPunCallbacks {
public GameObject cn;
public string isim;
public string arcane;
public string ıce;
public string flame;
public string elec;
public string posion;
public string divine;
public GameObject seçili;
public GameObject[] Wizards;
public GameObject[] WizardsObj;
public int wizsayi;
// Start is called before the first frame update
void Start()
{
WizardsObj[0].SetActive(true);
WizardsObj[1].SetActive(true);
WizardsObj[2].SetActive(true);
WizardsObj[3].SetActive(true);
WizardsObj[4].SetActive(true);
WizardsObj[5].SetActive(true);
seçili = WizardsObj[wizsayi];
for (int i = 0; i < Wizards.Length; i++)
{
Wizards[i].SetActive(false);
}
Wizards[wizsayi].SetActive(true);
}
void Update()
{
DontDestroyOnLoad(cn);
seçili = WizardsObj[wizsayi];
}
public void NextButton()
{
wizsayi++;
Wizards[wizsayi - 1].SetActive(false);
if (wizsayi > Wizards.Length - 1)
{
wizsayi = 0;
}
Wizards[wizsayi].SetActive(true);
}
public void PreButton()
{
wizsayi--;
Wizards[wizsayi + 1].SetActive(false);
if (wizsayi < 0)
{
wizsayi = 5;
}
if (wizsayi < 0)
{
Wizards[5].SetActive(true);
}
Wizards[wizsayi].SetActive(true);
}
public void ArcaneWizard()
{
//cn.SetActive(false);
isim = arcane;
seçili = WizardsObj[0];
SceneManager.LoadScene("Menu");
}
public void ElecWizard()
{
//cn.SetActive(false);
isim = elec;
seçili = WizardsObj[4];
SceneManager.LoadScene("Menu");
}
public void DivineWizard()
{
//cn.SetActive(false);
isim = divine;
seçili = WizardsObj[5];
SceneManager.LoadScene("Menu");
}
public void PosionWizard()
{
//cn.SetActive(false);
isim = posion;
seçili = WizardsObj[3];
SceneManager.LoadScene("Menu");
}
public void FlameWizard()
{
//cn.SetActive(false);
isim = flame;
seçili = WizardsObj[2];
SceneManager.LoadScene("Menu");
}
public void İceWizard()
{
//cn.SetActive(false);
isim = ıce;
seçili = WizardsObj[1];
SceneManager.LoadScene("Menu");
}
}
}
Spells:
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using Photon.Pun;
namespace Com.Kawaiisun.SimpleHostile { public class Multi_Attack : MonoBehaviourPunCallbacks { PhotonView pw; public float abc=10; Multi_vur vur; private bool OnTarget = false; private float startDelay = 0; private float startTime = 0; public Transform Shooter; public float speed = 10; public AnimationCurve Ease; // Start is called before the first frame update void Start() { abc = 10; vur = GetComponent(); } void OnTriggerEnter(Collider col) { if (col.tag == "") { Destroy(this.gameObject); }
}
// Update is called once per frame
void Update()
{
if (!pw.IsMine) return;
}
[PunRPC]
void OnEnable()
{
OnTarget = false;
startDelay = GetComponent<ParticleSystem>().main.startDelay.constant;
StartCoroutine(shootParticle());
}
void LateUpdate()
{
if (!OnTarget)
{
transform.position = Shooter.position;
}
else
{
transform.position = Vector3.MoveTowards(transform.position, vur.closestEnenmy.position, Ease.Evaluate(startTime));
startTime += Time.deltaTime * speed;
}
}
IEnumerator shootParticle()
{
yield return new WaitForSeconds(startDelay);
OnTarget = true;
startTime = 0;
}
void OnParticleCollision(GameObject other)
{
GetComponent<ParticleSystem>().Stop(true);
Debug.Log("particleCol");
}
public void StopUsAll()
{
GetComponent<ParticleSystem>().Stop(true);
Debug.Log("particleCol");
}
}
}
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Realtime; using Photon.Pun;
namespace Com.Kawaiisun.SimpleHostile {
public class Multi_Büyü : MonoBehaviourPunCallbacks
{
public PhotonView pw;
multiplayerc em;
Multi_vur vur;
Multi_Attack atc;
public int attackdamage;
void Start()
{
atc = GetComponent<Multi_Attack>();
vur = GetComponent<Multi_vur>();
//em = GetComponent<EnemyHealth>();
em = vur.closestEnenmy.GetComponent<multiplayerc>();
}
// Update is called once per frame
void Update()
{
if (!pw.IsMine) return;
}
void OnTriggerEnter(Collider Player)
{
Player.gameObject.GetComponent<multiplayerc>().TakeDamage(attackdamage,0);
}
}
}
using System.Collections; using System.Collections.Generic; using Photon.Realtime; using Photon.Pun; using UnityEngine;
namespace Com.Kawaiisun.SimpleHostile { public class Multi_vur : MonoBehaviourPunCallbacks { public PhotonView pw; public GameObject[] multipleEnemys; public Transform closestEnenmy; public bool enemyContact; public float hiz = 15;
public void Update()
{
if (!pw.IsMine) return;
transform.LookAt(closestEnenmy);
transform.position += transform.forward * hiz * Time.deltaTime;
closestEnenmy = GetClotestEnemy();
//closestEnenmy.gameObject.GetComponent<SpriteRenderer>().material.color = new Color(1, 0.7f, 0.1f);
}
public void Start()
{
}
public Transform GetClotestEnemy()
{
multipleEnemys = GameObject.FindGameObjectsWithTag("Player");
float closestDistance = Mathf.Infinity;
Transform trans = null;
foreach (GameObject go in multipleEnemys)
{
float currentDistance;
currentDistance = Vector3.Distance(transform.position, go.transform.position);
if (currentDistance < closestDistance)
{
closestDistance = currentDistance;
trans = go.transform;
}
}
return trans;
}
}
}
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun;
namespace Com.Kawaiisun.SimpleHostile { public class Multi_sağlık : MonoBehaviourPunCallbacks { public PhotonView pw; multiplayerc em; Multi_vur vur; Multi_Attack atc; public int attackdamage;
void Start()
{
atc = GetComponent<Multi_Attack>();
vur = GetComponent<Multi_vur>();
//em = GetComponent<EnemyHealth>();
em = vur.closestEnenmy.GetComponent<multiplayerc>();
}
// Update is called once per frame
void Update()
{
if (!pw.IsMine) return;
}
void OnTriggerEnter(Collider Player)
{
Player.gameObject.GetComponent<multiplayerc>().TakeDamage(-attackdamage, 0);
}
}
}
Spell controller:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Realtime; using Photon.Pun;
namespace Com.Kawaiisun.SimpleHostile { public class Multi_Kontrol_1 : MonoBehaviourPunCallbacks { public PhotonView pw; public multiplayerc pc;
// Start is called before the first frame update
void Start()
{
pc = GetComponent<multiplayerc>();
}
void Update()
{
if (!pw.IsMine) return;
if (pc.mana >= 10)
{
if (Input.GetKeyDown(KeyCode.Alpha0))
{
Instantiate(pc.sp0, pc.spawnPoskalkan.position, pc.spawnPoskalkan.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Instantiate(pc.sp1, pc.spawnPosportal1.position, pc.spawnPosportal1.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad0))
{
Instantiate(pc.sp0, pc.spawnPoskalkan.position, pc.spawnPoskalkan.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad1))
{
Instantiate(pc.sp1, pc.spawnPosportal1.position, pc.spawnPosportal1.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad8))
{
Instantiate(pc.sp8, pc.spawnPos.position, pc.spawnPos.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Keypad9))
{
Instantiate(pc.sp9, pc.spawnPos.position, pc.spawnPos.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha8))
{
Instantiate(pc.sp8, pc.spawnPos.position, pc.spawnPos.rotation);
pc.mana -= 10;
}
if (Input.GetKeyDown(KeyCode.Alpha9))
{
Instantiate(pc.sp9, pc.spawnPos.position, pc.spawnPos.rotation);
pc.mana -= 10;
}
}
}
}
}
Your answer
Follow this Question
Related Questions
main Camera Not Getting activeated 0 Answers
Both players take damage when hit?,both players take damage 0 Answers
(photon) weapon switch event is not visible for others (tried rpc) 0 Answers
How do I Update a Collider's Collison through script? 1 Answer
Both players reach same time how to get result draw in photon unity 1 Answer