void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player" && other.gameObject.GetComponent <PlayerPush>() != null) { canBePushed = true; player = other.gameObject; playerPush = other.gameObject.GetComponent <PlayerPush>(); blockSpeed = playerPush.playerSpeed; } }
void Start() { mPlayer = GameObject.FindWithTag("Player"); //change false if there is no interactable thing if (mPlayer == null) { //false button gameObject.SetActive(false); return; } script = mPlayer.GetComponent <PlayerPush>(); }
void Start() { BCD2 = bateria.GetComponent <BoxCollider2D>(); RB2D = bateria.GetComponent <Rigidbody2D>(); scriptPlayer = player.GetComponent <Player>(); follow = camara.GetComponent <FollowTarget>(); push = player.GetComponent <PlayerPush>(); anim = player.GetComponent <Animator>(); }
void Start() { Rb2D = GetComponent <Rigidbody2D>(); coll = GetComponent <BoxCollider2D>(); playerP = GetComponent <PlayerPush>(); anim = GetComponent <Animator>(); distToGround = coll.bounds.extents.y; gravity = (-(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2)) / Mathf.Abs(Physics2D.gravity.y); Rb2D.gravityScale = Mathf.Abs(gravity); jumpVelocity = Mathf.Abs(gravity * Mathf.Abs(Physics2D.gravity.y)) * timeToJumpApex; print("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity); }