void changeFocus(GameObject target) { playerScript.focus = false; player = target; playerScript = player.GetComponent <playerScript_ex00>(); playerScript.focus = true; }
private void Start() { if (defaultPlayer) { ActivePlayer = this; } }
void changeFocus(GameObject target) { playerScript.focus = false; player = target; playerScript = player.GetComponent<playerScript_ex00>(); playerScript.focus = true; }
// Use this for initialization void Start() { player = this; //print(selected_player2); selected_player++; id_player = selected_player; }
// Update is called once per frame void Update () { if (focussed == this) { if (Input.GetKeyDown("space")) { if (GetComponent<Collider2D>().IsTouchingLayers(mapLayer)) { tmp = GetComponent<Rigidbody2D>().velocity; tmp.y = jumpHeight; GetComponent<Rigidbody2D>().velocity = tmp; } } else if (Input.GetKey("left")) { tmp = GetComponent<Rigidbody2D>().velocity; tmp.x = -moveSpeed; GetComponent<Rigidbody2D>().velocity = tmp; } else if (Input.GetKey("right")) { tmp = GetComponent<Rigidbody2D>().velocity; tmp.x = moveSpeed; GetComponent<Rigidbody2D>().velocity = tmp; } } else if (Input.GetKeyDown(key)) { focussed = this; } if (Input.GetKeyDown("r")) { transform.localPosition = initialPos; GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f); } }
private void ChangePlayer(int index) { if (index >= players.Length) { return; } _activePlayer.enabled = false; _activePlayer = players[index]; _activePlayer.enabled = true; }
// Use this for initialization void Start() { initPos = new Vector3[] { new Vector3(-4.21F, -0.36F, 0), new Vector3(-1.44F, 0.26F, 0), new Vector3(1.69F, 0.25F, 0) }; resetPos(); player = red; playerScript = player.GetComponent <playerScript_ex00>(); playerScript.focus = true; }
// Use this for initialization void Start() { initPos = new Vector3[] { new Vector3(-4.21F, -0.36F, 0), new Vector3(-1.44F, 0.26F, 0), new Vector3(1.69F, 0.25F, 0) }; resetPos(); player = red; playerScript = player.GetComponent<playerScript_ex00>(); playerScript.focus = true; }
void OnTriggerEnter2D(Collider2D collision) { if (id > 10) { if (collision.gameObject.CompareTag("Player") || LayerMask.LayerToName(collision.gameObject.layer) == "Platforms" || collision.gameObject.CompareTag("" + (id - 10))) { playerScript_ex00 parent = this.transform.parent.GetComponent <playerScript_ex00>(); parent.grounds++; parent.grounded = true; } } }
void Start() { GameObject[] tmp; tmp = GameObject.FindGameObjectsWithTag("Player"); players = new playerScript_ex00[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { players[i] = tmp[i].GetComponent <playerScript_ex00>(); players[i].enabled = false; } if (players != null) { _activePlayer = players[0]; _activePlayer.enabled = true; } }
private void Update() { if (Input.GetKeyDown(key)) { ActivePlayer = this; } if (ActivePlayer != this) { return; } if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } var velocity = _rigidbody2D.velocity; if (Input.GetKey(KeyCode.LeftArrow)) { velocity.x = -moveSpeed; } else if (Input.GetKey(KeyCode.RightArrow)) { velocity.x = moveSpeed; } else { velocity.x = 0; } if (Input.GetKeyDown(KeyCode.Space)) { velocity.y = jumpPower; } _rigidbody2D.velocity = velocity; }
// Use this for initialization void Start () { initialPos = transform.localPosition; if (defaultFocussed) focussed = this; }