Stuck when want to make the AI in Turn-Based Strat

Chat about anything not covered in these forums, but keep it civil!

Post » Sat Dec 14, 2013 4:08 pm

Hai everyone, i already can make the movement grid via pathfinding and avoid obstacles for the player. Right now, i want to make the AI move itself based on the how many movement grid and the action point (just like the player does). But, i don't know how to do it.. Right now, i just able to make the character move to the position (but it is not follow the pathfinding, this character suppose to be the AI).. I am stack at this and try to solve this problem, but couldn't. Could you guys help me out? Thanks.

Here is the code that i mention in the above (can make the character which is suppose to be AI to move to the position, but it not follow the pathfinding):

EDIT: The problem that i couldn't figure it out is to make the AI act as player does. When you see the video that i uploaded in the youtube (link to that has been given on the question below), you will see on the first and second turn, i control the player to move and there is a GUI on left side of the screen (move, attack, magicattack and endturn), when the player's turn ends, AI's turn will active (if you see, there is no GUI and the AI move itself to point destination as described in the code below, but it is not following the pathfinding). My question is: how do i solve this? Thank you very much

Collapse | Copy Code
using UnityEngine;
using System.Collections;

public class AIPlayer : Player
{
    void Awake()
    {
        moveDestination = transform.position;
    }

    // Use this for initialization
    void Start()
    {
        ColorChanger();
    }

    // Update is called once per frame
    void Update()
    {

    }


    public override void TurnUpdate()
    {
        if (GameManager.instance.currentPlayerIndex == 5)
        {
            if (Vector3.Distance(moveDestination, transform.position) > 0.1f)
            {
               transform.position += (moveDestination - transform.position).normalized * moveSpeed * Time.deltaTime;

               if (Vector3.Distance(moveDestination, transform.position) <= 0.1f)
               {
                    transform.position = moveDestination;
                    actionPoints--;
               }
            }

            else
            {
               moveDestination = new Vector3(2 - Mathf.Floor(GameManager.instance.mapSize / 2), 1.5f, -2 + Mathf.Floor(GameManager.instance.mapSize / 2));
               GameManager.instance.NextTurn();
            }
        }

        base.TurnUpdate();
    }

    public override void TurnOnGUI()
    {

    }

    public override void ColorChanger()
    {
        base.ColorChanger();
    }
}
B
2
Posts: 1
Reputation: 152

Post » Sat Dec 14, 2013 4:46 pm

Why are you asking on the construct forum how to use unity? You should ask on their forums instead. They'll be able to help you much better.Arima2013-12-14 16:47:34
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744


Return to Open Topic

Who is online

Users browsing this forum: No registered users and 1 guest