// Initialisation void Awake() { spriteRenderer = GetComponent <SpriteRenderer> (); animator = GetComponent <Animator> (); world = GameObject.FindGameObjectWithTag("FrontGround").GetComponent <Tilemap>(); player = GameObject.FindGameObjectWithTag("Player").transform; Vector3 colliderSizeRes = Collider2DSize.GetColliderSize(GetComponents <Collider2D> ()); unitCollider.x = colliderSizeRes.x; unitCollider.y = colliderSizeRes.y; startingPosRaycastY = colliderSizeRes.z; }
private float startingPosRaycastY; // StartingYpos for the raycast of the unit in FollowPath function void Awake() { worldGrid = GameObject.FindGameObjectWithTag("grid").GetComponent <WorldGrid> (); spriteRenderer = GetComponent <SpriteRenderer> (); animator = GetComponent <Animator> (); unitCollider = Vector2.zero; target = GameObject.FindGameObjectWithTag("Player").transform; Vector3 colliderSizeRes = Collider2DSize.GetColliderSize(GetComponents <Collider2D> ()); unitCollider.x = colliderSizeRes.x; unitCollider.y = colliderSizeRes.y; startingPosRaycastY = colliderSizeRes.z; previousMove = Vector2.zero; move = Vector2.zero; }