// Update is called once per frame void Update() { if (joint.distance > 1f) { joint.distance -= step; } else { line.enabled = false; joint.enabled = false; } line.SetPosition(0, transform.position); line.SetPosition(1, ray.point); if (GetComponent <Transform>().localScale.x == .25) { curpos.x = transform.position.x + max; curpos.y = transform.position.y + max; curpos.z = 0; } if (GetComponent <Transform>().localScale.x == -.25) { curpos.x = transform.position.x - max; curpos.y = transform.position.y + max; curpos.z = 0; } if (Input.GetButtonDown("grapple") == true && inv.getElement(3) == true && GetComponent <Transform>().localScale.x == .25) { ray = Physics2D.Raycast(transform.position, curpos - transform.position, max, mask); if (ray.collider != null) { joint.enabled = true; joint.connectedBody = ray.collider.gameObject.GetComponent <Rigidbody2D>(); joint.distance = Vector2.Distance(transform.position, ray.point); line.enabled = true; } } if (Input.GetButtonDown("grapple") == true && inv.getElement(3) == true && GetComponent <Transform>().localScale.x == -.25) { ray = Physics2D.Raycast(transform.position, curpos, 10, mask); if (ray.collider != null) { joint.enabled = true; joint.connectedBody = ray.collider.gameObject.GetComponent <Rigidbody2D>(); joint.distance = Vector2.Distance(transform.position, ray.point); line.enabled = true; } } if (Input.GetButtonUp("grapple") == true) { joint.enabled = false; line.enabled = false; } }
// Update is called once per frame void Update() { if (inv.getElement(1) == true && Input.GetButtonDown("Fire1")) { pl.GetComponent <Rigidbody2D>().velocity = new Vector2(+0, height); } }
// Update is called once per frame void FixedUpdate() { if (Input.GetButtonDown("Fire2") && inv.getElement(0) == true) { player.GetComponent <Rigidbody2D>().velocity = new Vector2(+0, -downwardsForce); Debug.Log("added force"); inGP = true; Debug.Log("set inGP to " + inGP); } }
void FixedUpdate() { if (move.checkWall() == true && inv.getElement(2) == true) { if (Input.GetButtonDown("Fire3")) { if (tog == true) { tog = false; } else { tog = true; } } } if (move.checkWall() == false) { tog = false; } }
// Update is called once per frame void FixedUpdate() { if (Input.GetButtonDown("Fire3") && playerinv.getElement(2) == true) { cposx = player.GetComponent <Transform>().position.x; if (player.GetComponent <Transform>().localScale.x == .25) { endposx = cposx + dif; player.GetComponent <Rigidbody2D>().AddForce(new Vector2(cspeed * 100, 1)); incharge = true; pos = true; } else if (player.GetComponent <Transform>().localScale.x == -.25) { endposx = cposx - dif; player.GetComponent <Rigidbody2D>().AddForce(new Vector2((-1 * cspeed) * 100, 1)); incharge = true; neg = true; } } }