// Use this for initialization void Start() { playerController1 = GameObject.Find("player_1").GetComponent <PlayerController1>(); playerController2 = GameObject.Find("player_2").GetComponent <PlayerController2>(); timer = this.GetComponent <Timer>(); }
void ShootPlayer() { muzzleFlashEnemy.Play(); RaycastHit hit; if (Physics.Raycast(head.transform.position, head.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); PlayerController1 targetP = hit.transform.GetComponent <PlayerController1>(); if (targetP != null) { targetP.TakeDamagePlayer(damage); } if (damage <= 0) { SceneManager.LoadScene("Game_1"); } GameObject impactGO = Instantiate(impactEnemy, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 0.5f); } }
// Use this for initialization protected virtual void Awake() { body = GetComponent<Rigidbody2D>(); animalController = GetComponent<PlayerController1>(); animalController.enabled = false; animator = GetComponent<Animator>(); }
private PlayerController1 playerController1;//铅笔脚本,用于获取其isLying值 private void Start() { playerController1 = GetComponent <PlayerController1>(); // rb = GetComponent <Rigidbody2D>(); // anim = GetComponent <Animator>(); }
private void Awake() { GameObject player = GameObject.Find("Player"); PlayerController1 coin = player.GetComponent <PlayerController1>(); coins.text = "Coins: " + coin.score.ToString(); health.text = "Health: " + coin.health.ToString(); }
// Start is called before the first frame update void Start() { ResetHealth(); ResetAirTime(); playerController = this.gameObject.GetComponent <PlayerController1>(); lastCheckPoint = this.transform.position; }
void Awake() { _playerInput = GetComponent <PlayerInput>(); var playersController = FindObjectsOfType <PlayerController1>(); var index = _playerInput.playerIndex; _playerController1 = playersController.FirstOrDefault(m => m.GetPlayerIndex() == index); }
void Start() { GameOverPanel.SetActive(false); player1 = FindObjectOfType <PlayerController1>(); player2 = FindObjectOfType <PlayerController2>(); currentTime = gameTimer; ScoreController2.RestartScore(); announcements.text = ""; }
private void OnTriggerExit(Collider other) { PlayerController1 player = other.GetComponent <PlayerController1>(); if (player) { playerNr--; } }
private void OnTriggerEnter(Collider other) { PlayerController1 player = other.GetComponent <PlayerController1>(); if (player) { door.SetActive(false); } }
// Start is called before the first frame update void Start() { player = (PlayerController1)FindObjectOfType(typeof(PlayerController1)); velocity = Random.Range(1.5f, 3.5f); animator = GetComponent <Animator>(); rb2d = GetComponent <Rigidbody2D>(); rb2d.velocity = Vector2.up * velocity; collider2D = GetComponent <Collider2D>(); musicPlayer = GetComponent <AudioSource>(); GetRandomBalloon(); }
// Use this for initialization void Start() { // splitMass = GameObject.FindGameObjectWithTag("SplitMass").GetComponent<GameObject>(); // target = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>(); rigidBody2D = GetComponent <Rigidbody2D>(); gameManager = FindObjectOfType <GameManager>(); playerController1 = FindObjectOfType <PlayerController1>(); if (gameManager == null) { Print("No GameManager found!", "error"); } }
void OnTriggerExit2D(Collider2D collision) { Debug.Log("leaves oli"); if (collision.name.Equals("player_1")) { playerController1 = GameObject.Find("player_1").GetComponent <PlayerController1>(); playerController1.is_slipping = false; } else { playerController2 = GameObject.Find("player_2").GetComponent <PlayerController2>(); playerController2.is_slipping = false; } }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("enter oli"); if (other.name.Equals("player_1")) { playerController1 = GameObject.Find("player_1").GetComponent <PlayerController1>(); playerController1.is_slipping = true; } else { playerController2 = GameObject.Find("player_2").GetComponent <PlayerController2>(); playerController2.is_slipping = true; } }
// Turns player around to stand on new surface private void WalkAroundEdge(Vector3 point, Vector3 normal, PlayerController1 player) { // Store original position & rotation Vector3 originalPos = m_playerTrans.position; Quaternion originalRot = m_playerTrans.rotation; // Calculate target position and rotation // Move player above and little bit inside surface Vector3 targetPos = (m_playerTrans.position + normal) + m_playerTrans.up * -1.5f;// + m_playerTrans.forward * 1.1f; ; Vector3 playerForward = Vector3.Cross(m_playerTrans.right, normal); // Create new rotation out of (new) forward and up vector Quaternion targetRot = Quaternion.LookRotation(playerForward, normal); StartCoroutine(SmoothRotate(originalPos, originalRot, targetPos, targetRot, player)); }
private void OnTriggerEnter(Collider other) { PlayerController1 player = other.GetComponent <PlayerController1>(); if (player) { laserHit.Play(); GameObject playerBody = player.transform.GetChild(0).gameObject; player.GetComponent <PlayerController1>().enabled = false; Vector3 startPosition = playerBody.transform.eulerAngles; Vector3 endPosition = new Vector3(playerBody.transform.eulerAngles.x - 90, playerBody.transform.eulerAngles.y, playerBody.transform.eulerAngles.z); playerBody.transform.eulerAngles = Vector3.Lerp(startPosition, endPosition, 5.0f); StartCoroutine(Respawn()); } }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); if (player == null) { Debug.LogError("No player tag found in scene.:" + this.name); } pc = player.GetComponent <PlayerController1>(); if (pc == null) { Debug.LogError("No PlayerController found on the player"); } }
// Use this for initialization void Start() { playerController1 = GameObject.Find("player_1").GetComponent <PlayerController1>(); playerController2 = GameObject.Find("player_2").GetComponent <PlayerController2>(); trigger = GameObject.Find("finish_trigger").GetComponent <FinishTrigger>(); timer = gameObject.GetComponent <Timer>(); animator = GameObject.Find("win_message").GetComponent <Animator>(); audioData = GameObject.Find("win_message").GetComponent <AudioSource>(); backgroundMusic = GameObject.Find("MusicPlayer").GetComponent <AudioSource>(); sfx = GameObject.Find("MusicPlayer").GetComponent <AudioSource>(); player = 0; audioHasPlayed = false; backgroundMusic.Play(277830); }
private void OnTriggerEnter(Collider collider) { if (collider.tag == player.tag) { if (collider.tag == "Player2") { playerScript = collider.GetComponent <PlayerController1>(); playerScript.inDangerZone = true; Debug.Log("entered red zone"); } else if (collider.tag == "Playa") { playerScript = collider.GetComponent <PlayerController1>(); playerScript.inDangerZone = true; Debug.Log("entered blue zone"); } } }
private void OnTriggerEnter(Collider other) { BoxBehavior box = other.GetComponent <BoxBehavior>(); PlayerController1 player = other.GetComponent <PlayerController1>(); if (box) { box.transform.position = box.GetOrigPos(); Debug.Log("box here"); } else if (player) { fallSound.Play(); player.constantSpeed = 0; player.turnSpeed = 0; player.GetComponent <Rigidbody>().mass = 0.01f; StartCoroutine(Respawn()); } }
private void OnTriggerStay(Collider other) { PlayerController1 player = other.GetComponent <PlayerController1>(); if (player && !inGoal) { if (Input.GetKeyUp(KeyCode.I)) { if (!hasPSource) { player1 = player; hasPSource = true; } else { player1 = null; hasPSource = false; } } } }
void Boom() { Instantiate(efeitoBooom, transform.position, transform.rotation); Collider[] collidersDestruido = Physics.OverlapSphere(transform.position, radius); foreach (Collider nearbyObject in collidersDestruido) { Rigidbody rb = nearbyObject.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(forca, transform.position, radius); } PlayerController1 player = nearbyObject.GetComponent <PlayerController1>(); if (player != null) { player.TakeDamagePlayer(danoG); } } Destroy(gameObject); }
private void OnTriggerEnter(Collider other) { PlayerController1 player = other.GetComponent <PlayerController1>(); if (player) { player.DisableMovement(); m_playerTrans = player.transform; // Send ray down to get normal of surface Ray ray = new Ray(m_transform.position, -m_transform.up); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { WalkAroundEdge(hit.point, hit.normal, player); } // Set new gravity player.SetGravity(m_gravityVector); // Make player able to move again player.EnableMovement(); } }
void Start() { //currentHealth = maxHealth; //healthbar.SetMaxHealth(maxHealth); //Set variables to player1 or player2 if (gameObject.tag == "Playa") { isPlayer1 = true; isTagged = false; getAxisHorizontal = "Horizontal"; getAxisVertical = "Vertical"; getWallAxisHor = "HorizontalWall"; getWallAxisVert = "VerticalWall"; //for movement joystick = GameObject.FindWithTag("Joystick").GetComponent <DynamicJoystick>(); //for wall spawn positioning wallJoystick = GameObject.FindWithTag("wallJoystick").GetComponent <FixedJoystick>(); //listener for //GameObject.FindWithTag("wallJoystick").GetComponent<Button>().onClick.AddListener(DeployWall); GameObject.FindWithTag("Joybutton").GetComponent <Button>().onClick.AddListener(DeployBomb); //GameObject.FindWithTag("JoybuttonWall").GetComponent<Button>().onClick.AddListener(DeployWall); carryFlag = GameObject.FindWithTag("Carry Flag"); otherPlayerScript = GameObject.FindWithTag("Player2").GetComponent <PlayerController1>(); } else if (gameObject.tag == "Player2") { isPlayer1 = false; getAxisHorizontal = "Horizontal2"; getAxisVertical = "Vertical2"; getWallAxisHor = "HorizontalWall2"; getWallAxisVert = "VerticalWall2"; joystick = GameObject.FindWithTag("Joystick2").GetComponent <DynamicJoystick>(); wallJoystick = GameObject.FindWithTag("wallJoystick2").GetComponent <FixedJoystick>(); //GameObject.FindWithTag("wallJoystick2").GetComponent<Button>().onClick.AddListener(DeployWall); GameObject.FindWithTag("Joybutton2").GetComponent <Button>().onClick.AddListener(DeployBomb); //GameObject.FindWithTag("JoybuttonWall2").GetComponent<Button>().onClick.AddListener(DeployWall); carryFlag = GameObject.FindWithTag("Carry Flag 2"); otherPlayerScript = GameObject.FindWithTag("Playa").GetComponent <PlayerController1>(); } //warningText = warningTextBox.GetComponent<Text>(); carryFlag.SetActive(false); isCarryingFlag = false; flagIsDropped = false; rb = GetComponent <Rigidbody>(); wallCount = 10; bombCount = 6; //SetWallCountText(); wallCountText.text = "Walls: " + wallCount.ToString(); SetBombCountText(); winningScreen.gameObject.SetActive(false); winnerText.text = ""; m_Gyro = Input.gyro; m_Gyro.enabled = true; }
// Update is called once per frame void Update() { gameTimer += Time.deltaTime; bombRespawnTimer += Time.deltaTime; //Debug.Log(gameTimer); if (bombRespawnTimer > 10) { bombCount += 1; SetBombCountText(); bombRespawnTimer = 0; } //Debug.Log(Input.gyro.rotationRateUnbiased); shakoMeter = Input.gyro.rotationRateUnbiased; if (shakoMeter.x > 3f || shakoMeter.y > 3f || shakoMeter.z > 2.5f || shakoMeter.x < -3f || shakoMeter.y < -3f || shakoMeter.z < -2.5f) { Debug.Log("YOU SHAKING!!!!!\nSHAKKINGGG\nSHAKKEEINGG"); } Vector3 moveDirection = new Vector3(Input.GetAxis(getAxisHorizontal), 0.0f, Input.GetAxis(getAxisVertical)); moveDirectionWithSpeed = moveDirection * speed; Vector3 moveDirectionJoystick = new Vector3(joystick.Horizontal, 0.0f, joystick.Vertical); moveDirectionWithSpeedJoystick = moveDirectionJoystick * speed; wallDirectionJoystick = new Vector3(wallJoystick.Horizontal, 0.0f, wallJoystick.Vertical); //this decides if the player is on computer keyboard or mobile device if (moveDirection != Vector3.zero) { combinedMoveDirectionWithSpeed = moveDirectionWithSpeed; } else { combinedMoveDirectionWithSpeed = moveDirectionWithSpeedJoystick; moveDirection = moveDirectionJoystick; } //move the player rb.velocity = combinedMoveDirectionWithSpeed; //rotate the player when it turns if (moveDirection != Vector3.zero) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(moveDirection.normalized), 0.5f); } //RaycastHit theHit; //if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out theHit)) //{ // if (theHit.collider.gameObject.tag == "Wall") // { // Debug.Log("WALLLL!!!!"); // distanceFromObj = theHit.distance * 100; // } //} //DROPPING PREFABS(WALLS AND BOMBS) SECTION //bomb cooldown conditional if (bombCooldown > 0 && !isBombCooledDown) { bombCooldown -= Time.deltaTime; } else if (bombCooldown <= 0) { isBombCooledDown = true; } if ((Input.GetKeyDown(KeyCode.Space) && isPlayer1 && bombCount > 0 && isBombCooledDown) || (Input.GetKeyDown(KeyCode.Period) && !isPlayer1 && bombCount > 0 && isBombCooledDown)) { //what to spawn, where to spawn, which direction to spawn in Instantiate(bomb, new Vector3(transform.position.x, transform.position.y - 0.4f, transform.position.z) + (transform.forward * 2), transform.rotation); bombCount -= 1; SetBombCountText(); bombCooldown = bombCooldownDefault; isBombCooledDown = false; } else if ((Input.GetKeyDown(KeyCode.Space) && isPlayer1 && bombCount == 0) || (Input.GetKeyDown(KeyCode.Period) && !isPlayer1 && bombCount == 0)) { Debug.Log("Player out of bombs"); SetBombCountText(); setWarningText("bomb"); } //WALL INSTANTIATE FOR KEYS if ((Input.GetKeyDown(KeyCode.V) && isPlayer1 && wallCount > 0) || (Input.GetKeyDown(KeyCode.Comma) && !isPlayer1 && wallCount > 0)) { Instantiate(wall, transform.position + (transform.forward * 2), transform.rotation); wallCount -= 1; SetWallCountText(); } else if ((Input.GetKeyDown(KeyCode.V) && isPlayer1 && wallCount == 0) || (Input.GetKeyDown(KeyCode.Comma) && !isPlayer1 && wallCount == 0)) { Debug.Log("Player 1 out of walls"); SetWallCountText(); setWarningText("wall"); } if ((Input.GetKeyDown(KeyCode.C) && isPlayer1) || (Input.GetKeyDown(KeyCode.L) && !isPlayer1)) { isCarryingFlag = false; flagIsDropped = true; carryFlag.SetActive(false); //GameObject.FindWithTag("Flag2").SetActive(true); } Collider[] zones = Physics.OverlapSphere(transform.position, 0f); foreach (Collider zone in zones) { } Collider[] hits = Physics.OverlapSphere(transform.position, overlapColliderRange); foreach (Collider hit in hits) { if ((hit.tag == "Player2" && isCarryingFlag && isPlayer1) || (hit.tag == "Playa" && isCarryingFlag && !isPlayer1)) { isCarryingFlag = false; flagIsDropped = true; carryFlag.SetActive(false); Debug.Log("TAGGED!!! DROP THE GEM!"); setWarningText("tagged with gem"); } else if ((hit.tag == "Player2" && isPlayer1 && inDangerZone && !isTagged) || (hit.tag == "Playa" && !isPlayer1 && inDangerZone && !isTagged)) { PlayerController1 taggedPlayerScript = hit.GetComponent <PlayerController1>(); int wallPenalty = wallCount / 2; taggedPlayerScript.wallCount += wallPenalty; taggedPlayerScript.SetWallCountText(); wallCount = wallPenalty; SetWallCountText(); int bombPenalty = bombCount / 2; taggedPlayerScript.bombCount += bombPenalty; taggedPlayerScript.SetBombCountText(); bombCount = bombPenalty; SetBombCountText(); isTagged = true; Debug.Log("NICE ONE " + hit.tag + "! You took " + wallPenalty + " walls and " + bombPenalty + " bombs"); setWarningText("tagged"); } } }
// Start is called before the first frame update void Start() { Instantiate(flag, new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z), transform.rotation); player = GameObject.FindWithTag("Player2"); playerScript = player.GetComponent <PlayerController1>(); }
// Use this for initialization void Start() { myPlayer = FindObjectOfType <PlayerController1>(); coinText.text = "Coins: 0"; healthCount = maxHealth; }
protected virtual void OnTriggerEnter2D(Collider2D other) { if (other.isTrigger || isSeated) return; Transform root = other.transform.root.transform; if (root.CompareTag("Player")) { playerTransform = root; playerController = root.GetComponent<PlayerController1>(); Seated(); } }
//Smooth transition between both positions private IEnumerator SmoothRotate(Vector3 originalPos, Quaternion originalRot, Vector3 targetPos, Quaternion targetRot, PlayerController1 player) { for (float t = 0.0f; t < 1.0f;) { t += Time.deltaTime; player.transform.position = Vector3.Lerp(originalPos, targetPos, t); player.transform.rotation = Quaternion.Slerp(originalRot, targetRot, t); yield return(null); // return here next frame } }
// Start is called before the first frame update void Start() { playerController = FindObjectOfType <PlayerController1>(); playerController2 = FindObjectOfType <PlayerController2>(); playerPosition = playerController.transform.position; }
void Start() { thePlayer = FindObjectOfType <PlayerController1>();//etsii PlayerController1:en lastPlayerPosition = thePlayer.transform.position; }
private void Start() { pc = GetComponentInParent <PlayerController1>(); }