コード例 #1
0
 // Use this for initialization
 void Start()
 {
     GameObject[] targets = GameObject.FindGameObjectsWithTag("Player");
     if (targets.Length > 0)
     {
         _target = targets[0];
     }
     _movement = gameObject.GetComponent <MoveTowardsDirection>();
 }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit objectClicked;

        if (Physics.Raycast(ray, out objectClicked) && objectClicked.transform.tag != "Player")
        {
            Vector3 target = objectClicked.transform.tag == "Ground" ? objectClicked.point : objectClicked.transform.position;
            MoveTowardsDirection movement = gameObject.GetComponent <MoveTowardsDirection>();
            movement.direction = MovementHelper.calculateNormalizedDirection(transform.position, target);
        }
    }
コード例 #3
0
    public void StopMovement(GameObject target)
    {
        MoveTowardsDirection movement = target.GetComponent <MoveTowardsDirection>();

        if (movement)
        {
            movement.direction = Vector3.zero;
        }
        else
        {
            Debug.LogError("Target must have component MoveTowardsDirection to Stop Movement", target);
        }
    }
コード例 #4
0
ファイル: PlayerMove.cs プロジェクト: reparadocs/mypocalypse
 // Use this for initialization
 void Start()
 {
     destination = transform.position;
     _movement   = gameObject.GetComponent <MoveTowardsDirection>();
 }