Ejemplo n.º 1
0
    private void CreateRoadMesh()
    {
        var roadMesh = pathCreator.GetComponent <RoadMeshCreator>();

        roadMesh.roadWidth = 25f;
        roadMesh.TriggerUpdate();
    }
Ejemplo n.º 2
0
    private void drawPathLine()     //inputu aldığımız kısım (çizim yapılan kısım)
    {
        if (Input.GetButtonDown("Fire1"))
        {
            if (check() == "Player")
            {
                a = 1;
            }

            else if (check() == "Friend")
            {
                a = 2;
            }

            else if (check() == "Ground")
            {
                a = 3;
            }

            points.Clear();
        }

        if (Input.GetButton("Fire1"))
        {
            if (Input.GetButton("Fire1"))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hitInfo;
                if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity, _layerMask, QueryTriggerInteraction.Ignore))
                {
                    if (a == 1)
                    {
                        if (DistanceToLastPoint(hitInfo.point) > 1f)
                        {
                            var point = hitInfo.point;
                            point.y = 0.6f;
                            points.Add(point);
                            lineRenderer.positionCount = points.Count;
                            lineRenderer.SetPositions(points.ToArray());
                        }
                    }

                    if (a == 2)
                    {
                        if (DistanceToLastPoint(hitInfo.point) > 1f)
                        {
                            pointsFriend.Add(hitInfo.point);
                            lineRenderer.positionCount = pointsFriend.Count;
                            lineRenderer.SetPositions(pointsFriend.ToArray());
                        }
                    }
                }
            }
        }

        else if (Input.GetButtonUp("Fire1"))
        {
            {
                if (a == 1) //player
                {
                    camerafollow = true;
                    var pathPoints = CreatePath(player.transform, target.transform, lineRenderer);
                    if (pathPoints != null)
                    {
                        animatorPlayer.SetBool("walk", true);
                        LineCount++;
                        bezierPath = new BezierPath(pathPoints, false, PathSpace.xyz);
                        pathCreator_Player.GetComponent <PathCreator>().bezierPath = bezierPath;
                        bezierPath.GlobalNormalsAngle = 90;
                        player.GetComponent <PathFollower>().enabled = true;
                        friend.GetComponent <PathFollower>().enabled = false;
                    }
                    else
                    {
                        lineRenderer.positionCount = 0;
                        animatorPlayer.SetBool("walk", false);
                    }
                }

                if (a == 2) //friend
                {
                    animatorFriend.SetBool("walk2", true);
                    bezierPathFriend = new BezierPath(pointsFriend, false, PathSpace.xyz);
                    pathcreatorfriend.GetComponent <PathCreator>().bezierPath = bezierPathFriend;
                    bezierPathFriend.GlobalNormalsAngle          = 90;
                    player.GetComponent <PathFollower>().enabled = false;
                    friend.GetComponent <PathFollower>().enabled = true;
                    LineCount++;
                }
                else
                {
                    animatorFriend.SetBool("walk2", false);
                }

                if (a == 3) //ground
                {
                    player.GetComponent <PathFollower>().enabled = false;
                    friend.GetComponent <PathFollower>().enabled = false;
                }
            }
        }
    }
Ejemplo n.º 3
0
 public PathCreator SetPath(PathCreator path)
 {
     //Debug.Log("I am assigned a path");
     return(myPath = path.GetComponent <PathCreator>());
 }