//Function to hold the raycasts at its place in relation to the object scale public void ScaleToOffsetPoints() { bool rayReplace = true; if (rayReplace == true) { float oldHalfRayLength = halfRayLength; //this fixes a bug where the left and right rays will switch because the x scale is minus. this way it tackles it if (transform.localScale.x >= 0) { halfRayWidth = width / 2 * transform.localScale.x; } else if (transform.localScale.x < 0) { halfRayWidth = width / 2 * -transform.localScale.x; } halfRayLength = length / 2 * transform.localScale.y; moveDown = new RaycastMoveDirection(new Vector2(-halfRayWidth, -halfRayLength), new Vector2(halfRayWidth, -halfRayLength), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen); moveLeft = new RaycastMoveDirection(new Vector2(-halfRayWidth, -halfRayLength), new Vector2(-halfRayWidth, halfRayLength), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicularInsetLen); moveUp = new RaycastMoveDirection(new Vector2(-halfRayWidth, halfRayLength), new Vector2(halfRayWidth, halfRayLength), Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicularInsetLen); moveRight = new RaycastMoveDirection(new Vector2(halfRayWidth, -halfRayLength), new Vector2(halfRayWidth, halfRayLength), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicularInsetLen); groundDown = new RaycastCheckTouch(new Vector2(-halfRayWidth, -halfRayLength), new Vector2(halfRayWidth, -halfRayLength), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen, groundTestLen); transform.position = new Vector3(transform.position.x, transform.position.y + oldHalfRayLength / 2, transform.position.z); rayReplace = false; } }
void Start() { sr = GetComponent <SpriteRenderer>(); moveDown = new RaycastMoveDirection(new Vector2(-0.5f, 0f), new Vector2(0.5f, 0f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicualrInsetLen); moveLeft = new RaycastMoveDirection(new Vector2(-0.5f, 0f), new Vector2(-0.5f, 1.7f), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicualrInsetLen); moveUp = new RaycastMoveDirection(new Vector2(-0.5f, 1.7f), new Vector2(0.5f, 1.7f), Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicualrInsetLen); moveRight = new RaycastMoveDirection(new Vector2(0.5f, 0f), new Vector2(0.5f, 1.7f), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicualrInsetLen); groundDown = new RaycastCheckTouch(new Vector2(-0.5f, 0f), new Vector2(0.5f, 0f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicualrInsetLen, groundTestLen); }
// Start is called before the first frame update protected void Awake() { moveDown = new RaycastMoveDirection(new Vector2(-0.5f, 0f), new Vector2(0.5f, 0f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicualrInsetLen); moveLeft = new RaycastMoveDirection(new Vector2(-0.5f, 0f), new Vector2(-0.5f, 1.7f), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicualrInsetLen); moveUp = new RaycastMoveDirection(new Vector2(-0.5f, 1.7f), new Vector2(0.5f, 1.7f), Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicualrInsetLen); moveRight = new RaycastMoveDirection(new Vector2(0.5f, 0f), new Vector2(0.5f, 1.7f), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicualrInsetLen); groundDown = new RaycastCheckTouch(new Vector2(-0.5f, 0f), new Vector2(0.5f, 0f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicualrInsetLen, groundTestLen); }
void Start() { killEnemies = GetComponent <killEnemies>(); outlineShades = Outline.GetComponentsInChildren <SpriteRenderer>(); trail = GetComponent <TrailRenderer>(); boundsTopRight.y = /*transform.position.y + */ GetComponent <Renderer>().bounds.extents.y; boundsTopRight.x = /*transform.position.x + */ GetComponent <Renderer>().bounds.extents.x; boundsBottomLeft.y = /*transform.position.y + */ GetComponent <Renderer>().bounds.extents.y * -1; boundsBottomLeft.x = /*transform.position.x + */ GetComponent <Renderer>().bounds.extents.x * -1; hitBox = GetComponent <CircleCollider2D>(); hurtBox = GetComponent <BoxCollider2D>(); platformMask = LayerMask.GetMask("Ground"); ////Downwards HitBox moveDown = new RaycastMoveDirection(boundsBottomLeft, new Vector2(boundsTopRight.x, boundsBottomLeft.y), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen); //Leftwards HitBox moveLeft = new RaycastMoveDirection(boundsBottomLeft, new Vector2(boundsBottomLeft.x, boundsTopRight.y), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicularInsetLen); //Upwards Hitbox moveUp = new RaycastMoveDirection(new Vector2(boundsBottomLeft.x, boundsTopRight.y), boundsTopRight, Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicularInsetLen); //Rightwards Hitbox moveRight = new RaycastMoveDirection(new Vector2(boundsTopRight.x, boundsBottomLeft.y), boundsTopRight, Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicularInsetLen); //GroundCheck; groundDown = new RaycastCheckTouching(boundsBottomLeft, new Vector2(boundsTopRight.x, boundsBottomLeft.y), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen, groundCheckLen); //Climbcheck Right wallRight = new RaycastCheckTouching(new Vector2(0.7f, -2.3f), new Vector2(0.7f, 2.0f), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicularInsetLen, wallCheckLen); //Climbcheck Left wallLeft = new RaycastCheckTouching(new Vector2(-0.7f, -2.3f), new Vector2(-0.7f, 2.0f), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicularInsetLen, wallCheckLen); }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); playerAnim = GetComponent <PlayerAnim>(); boxCollider = GetComponent <BoxCollider2D>(); audioManager = FindObjectOfType <AudioManager>(); moveDown = new RaycastMoveDirection(new Vector2(-0.5f, -0.75f), new Vector2(0.5f, -0.75f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen); moveLeft = new RaycastMoveDirection(new Vector2(-0.5f, -0.75f), new Vector2(-0.5f, 0.75f), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicularInsetLen); moveUp = new RaycastMoveDirection(new Vector2(-0.5f, 0.75f), new Vector2(0.5f, 0.75f), Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicularInsetLen); moveRight = new RaycastMoveDirection(new Vector2(0.5f, -0.75f), new Vector2(0.5f, 0.75f), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicularInsetLen); groundDown = new RaycastCheckTouch(new Vector2(-0.5f, -0.75f), new Vector2(0.5f, -0.75f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen, groundTestLen); }
void Start() { facingRight = true; // atira o raycast moveDown = new RaycastMoveDirection(new Vector2(-0.5f, -0.70f), new Vector2(0.5f, -0.70f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen); moveLeft = new RaycastMoveDirection(new Vector2(-0.5f, -0.70f), new Vector2(-0.5f, 0.70f), Vector2.left, platformMask, Vector2.up * parallelInsetLen, Vector2.right * perpendicularInsetLen); moveRight = new RaycastMoveDirection(new Vector2(0.5f, -0.70f), new Vector2(0.5f, 0.70f), Vector2.right, platformMask, Vector2.up * parallelInsetLen, Vector2.left * perpendicularInsetLen); moveUp = new RaycastMoveDirection(new Vector2(-0.5f, 0.70f), new Vector2(0.5f, 0.70f), Vector2.up, platformMask, Vector2.right * parallelInsetLen, Vector2.down * perpendicularInsetLen); groundDown = new RaycastCheckTouch(new Vector2(-0.5f, -0.70f), new Vector2(0.5f, -0.70f), Vector2.down, platformMask, Vector2.right * parallelInsetLen, Vector2.up * perpendicularInsetLen, groundTestLen); animator = GetComponent <Animator>(); spriteRenderer = GetComponent <SpriteRenderer>(); extraJumps = extraJumpsValue; weapon = GetComponent <Weapon>(); }