- Home /
Question by
hamoo7dfuad · Jan 28 at 12:01 PM ·
c#multiplayergameobjectslistsduplicate
Why does the script don't apply to the other duplicated player
Hi, I'm trying to make a multiplayer game so I was trying to test it out by duplicating the player but it doesn't work like the original player I have a ball script it works only with the original player not the duplicated player, sorry guys I'm a beginner programmer
private GrabController grabScript;
public GameObject Player
private Animator anim;
private SpriteRenderer spriteRenderer;
private Rigidbody2D rb2d;
public class Ball : MonoBehaviour
{
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
grabScript = Player.GetComponent<GrabController>();
spriteRenderer = GetComponent<SpriteRenderer>();
anim = GetComponent<Animator>();
}
void Update()
{
if(grabScript.isGrabed == true)
{
{
rb2d.gravityScale = 0f;
spriteRenderer.enabled = false;
anim.SetBool("stop", true);
rb2d.constraints = RigidbodyConstraints2D.None;
}
else
{
rb2d.gravityScale = 1.1f;
spriteRenderer.enabled = true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How to add and remove objects from a list when they get destroyed and instantiated 0 Answers
How do i activate a function attached to a listed GameObject from the perspective of itself? 1 Answer
One List of GameObjects of different types... 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers