RunnerBehavior.Movement C# (CSharp) Method

Movement() public method

public Movement ( Ray2D ry ) : void
ry Ray2D
return void
    public void Movement(Ray2D ry)
    {
        //Casts a ray in front of the object to see if there are any obstacles blocking the path
        if (Physics2D.Raycast(ry.origin,ry.direction,wallDist,whatIsWall))
        {
            //Changes the Direction the object faces to the opposite of its current Direction
            if (charging) {
                charging = false;
                speed = 0;
                pause = true;
                StartCoroutine (Stunned (1.5f));
            } else {
                Flip ();
                facingDir = new Vector2 (-facingDir.x, facingDir.y);
            }
        }

        //Move forward
        transform.Translate(facingDir * speed * Time.deltaTime);

        //Draws the Raycast so it is viewable in the editor
        Debug.DrawRay (ry.origin, ry.direction*wallDist, Color.red);
    }