Beispiel #1
0
        private void LookingAngle()
        {
            Vector3 pz               = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mouse            = new Vector2(pz.x, pz.y);
            Vector2 vectorFromCenter = new Vector2(mouse.x - rb.position.x, mouse.y - rb.position.y);
            double  angle            = AngleHelper.GetAngleForTurningAround(vectorFromCenter);

            AnalyzeAngle(angle);
        }
Beispiel #2
0
        private void Movement()
        {
            var    position                 = Character.transform.position;
            var    vectorFromCenter         = new Vector2(position.x - transform.position.x, position.y - transform.position.y);
            double angle                    = AngleHelper.GetAngleForTurningAround(vectorFromCenter);
            var    angleFromSectorBeginning = angle + (Constants.Round / NumOfSpriteTurns) / 2;

            int spriteNr = (int)(angleFromSectorBeginning / (Constants.Round / NumOfSpriteTurns));

            if (spriteNr < 0 || spriteNr == NumOfSpriteTurns)
            {
                spriteNr = 0;
            }
        }
Beispiel #3
0
        protected void ChangeAnimation(Vector2 vectorFromCenter)
        {
            double angle = AngleHelper.GetAngleForTurningAround(vectorFromCenter);
            var    angleFromSectorBeginning = angle + (Constants.Round / NumOfSpriteTurns) / 2;

            int spriteNr = (int)(angleFromSectorBeginning / (Constants.Round / NumOfSpriteTurns));

            if (spriteNr < 0 || spriteNr == NumOfSpriteTurns)
            {
                spriteNr = 0;
            }
            if (PrevBehaviour == spriteNr)
            {
                return;
            }
            Animator.SetInteger("angle", spriteNr); //throwing warning - need to expect this
            PrevBehaviour = spriteNr;
        }