void OnTriggerEnter2D(Collider2D other) { if (other.isTrigger) { return; } // Get necessary data about character falling in the hole: GameObject chara = other.gameObject; PlayerControls pc = other.GetComponent <PlayerControls>(); PlayerDetect pd = other.GetComponent <PlayerDetect>(); // Stop any future movement: if (pc) { pc.baseSpeed = 0.0f; } if (pd) { pd.movementSpeed = 0.0f; } // Record them: characterFallingTimes.Add(fallTime); charactersFalling.Add(chara); // Move them to the middle of the hole: chara.transform.position = transform.position; }
void Update() { if (hitPoints <= 0) { if (displayGameOver) { // display end of game message; set agents to idle displayGameOver.text = "Game Over :("; GameObject[] enemies = GameObject.FindGameObjectsWithTag("enemy"); foreach (GameObject enemy in enemies) { PlayerDetect pldt = enemy.GetComponent <PlayerDetect>(); pldt.idle(); pldt.movementSpeed = 0.0f; } } Destroy(gameObject); } if (hitPoints != oldValue) { Debug.Log("i have " + hitPoints + "hp left"); if (displayHP) { displayHP.text = hitPoints + " HP"; } oldValue = hitPoints; } }
new void Awake() { base.Awake(); currentSpeed = speed; pD = GetComponentInChildren <PlayerDetect>(); efd = GetComponentInChildren <GroundChecker>(); }
protected void Awake() { if (detectPlayer) { pDetect = GetComponentInChildren <PlayerDetect>(); } eh = GetComponentInChildren <EnemyHealth>(); anim = GetComponent <Animator>(); rigid = GetComponent <Rigidbody2D>(); }
void Update() { if (moveing) { PosAnimate(); } else { moveing = PlayerDetect.InputToDirection(); //Debug.Log(PlayerDetect.direction); animator.SetInteger("Direction", PlayerDetect.direction); if (moveing) { remPosition = transform.position; moveing = true; moveing = PlayerDetect.Wall(transform.position); //PlayerDetect.Grass(ref grass1, ref grass2, grassImage1, grassImage2, grassImage3); PlayerDetect.Grass(ref baseGrassObject, ref grass2, grassImage1, grassImage2, grassImage3); } } }
// Start is called before the first frame update new void Awake() { base.Awake(); boxCol = GetComponent <BoxCollider2D>(); pD = GetComponentInChildren <PlayerDetect>(); }
// Start is called before the first frame update new void Awake() { base.Awake(); pD = GetComponentInChildren <PlayerDetect>(); }
new void Awake() { base.Awake(); velocity = swimVelocity; detect = GetComponentInChildren <PlayerDetect>(); }