void changeFocus(GameObject target) { playerScript.focus = false; player = target; playerScript = player.GetComponent <playerScript_ex01>(); playerScript.focus = true; }
private void Start() { if (defaultPlayer) { ActivePlayer = this; } }
void changeFocus(GameObject target) { playerScript.focus = false; player = target; playerScript = player.GetComponent<playerScript_ex01>(); playerScript.focus = true; }
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(-14.41F, -2.53F, 0), new Vector3(-13.38F, -1.92F, 0), new Vector3(-11.51F, -1.9F, 0) }; resetPos(); player = red; playerScript = player.GetComponent <playerScript_ex01>(); playerScript.focus = true; }
// Use this for initialization void Start() { initPos = new Vector3[] { new Vector3(-14.41F, -2.53F, 0), new Vector3(-13.38F, -1.92F, 0), new Vector3(-11.51F, -1.9F, 0) }; resetPos(); player = red; playerScript = player.GetComponent<playerScript_ex01>(); 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_ex01 parent = this.transform.parent.GetComponent <playerScript_ex01>(); parent.grounds++; parent.grounded = true; } } }
void Start() { GameObject[] tmp; tmp = GameObject.FindGameObjectsWithTag("Player"); players = new playerScript_ex01[tmp.Length]; for (int i = 0; i < tmp.Length; i++) { players[i] = tmp[i].GetComponent <playerScript_ex01>(); players[i].enabled = false; } if (players != null) { _activePlayer = players[0]; _activePlayer.enabled = true; } }
private void OnTriggerEnter2D(Collider2D other) { if (!other.CompareTag("Player")) { return; } playerScript_ex01 player = other.gameObject.GetComponent <playerScript_ex01>(); if (player == null) { return; } if (player.index == playerIndex) { GameManager.instance.CharacterFinished(playerIndex, 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) && _isGrounded) { velocity.y = jumpPower; _isGrounded = false; } _rigidbody2D.velocity = velocity; }
// Update is called once per frame void Update () { if (!exit && focussed == this) { if (Input.GetKeyDown("space")) { if (GetComponent<Collider2D>().IsTouchingLayers(mapLayer)) { tmpVelocity = GetComponent<Rigidbody2D>().velocity; tmpVelocity.y = jumpHeight; GetComponent<Rigidbody2D>().velocity = tmpVelocity; GetComponent<Rigidbody2D>().AddForce(Vector3.up * jumpHeight); } } else if (Input.GetKey("left")) { tmpVelocity = GetComponent<Rigidbody2D>().velocity; tmpVelocity.x = -moveSpeed; GetComponent<Rigidbody2D>().velocity = tmpVelocity; } else if (Input.GetKey("right")) { tmpVelocity = GetComponent<Rigidbody2D>().velocity; tmpVelocity.x = moveSpeed; GetComponent<Rigidbody2D>().velocity = tmpVelocity; } } else if (Input.GetKeyDown(key)) { focussed = this; } if (Input.GetKeyDown("r")) { transform.localPosition = initialPos; GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f); } }
// Use this for initialization void Start() { player = transform.parent.gameObject.GetComponent <playerScript_ex01>(); }
void Start() { perso = GetComponentInParent <playerScript_ex01> (); }
// Use this for initialization void Start () { initialPos = transform.localPosition; if (defaultFocussed) focussed = this; }