Object is instanciate on the wrong player

Options
Hi everybody!
i have some trouble with instanciate prefab to my player
I try to instanciate a object locally to my player, but when i use
"Instantiate(UpAnimation, player.transform.position, player.transform.rotation);"
This is appear on the wrong player..

i try to do this with view.IsMine but nothing change :/...

Good night! :)

Comments

  • redskry
    redskry
    edited April 2017
    Options
    Up :) all work on mlutiplayer , but when i connect 2Client, the "UpAnimation" is instanciate at the positionof the other client..

    There is my script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;


    public class PlayerStats : MonoBehaviour
    {

    PhotonView _view;
    public int playerHealth;
    public int currentPlayerHealth;
    public GameObject checkpoint;
    public Vector2 checkpointPosition;
    public int currentLevel;
    public int currentExp;
    public int[] toLevelUp;
    Text levelText;
    public int maxXp;
    Text XPText;
    public GameObject UpAnimation;



    void Start()
    {

    _view = GetComponent();

    currentPlayerHealth = playerHealth;
    checkpointPosition = checkpoint.transform.position;
    addExperience(0);
    levelText = GameObject.Find("LvlText").GetComponent();
    XPText = GameObject.Find("XpText").GetComponent();

    }

    void Update()
    {
    levelText.text = "Lvl: " + currentLevel;
    XPText.text = "XP : " + currentExp + "/" + maxXp;

    }

    public void addExperience(int experienceToAdd)
    {

    currentExp += experienceToAdd;

    if (currentExp >= toLevelUp[currentLevel])
    {

    currentLevel++;
    maxXp = toLevelUp[currentLevel];
    Debug.Log(" UP !!");
    Instantiate(UpAnimation, transform.FindChild("PlayerInstanciate").transform.position, transform.rotation);

    }

    }


    public void TakeDamage(int damage)
    {

    currentPlayerHealth -= damage;


    if (currentPlayerHealth <= 0)
    {
    transform.position = checkpointPosition;
    currentPlayerHealth = playerHealth;

    }
    }
    }