Tag Info

New answers tagged

0

This should do the job, it will follow the player and face the player as well. Hope this helped. using UnityEngine; using System.Collections; public class ChasePlayerAI : MonoBehaviour { public Transform target;//set target from inspector instead of looking in Update public float speed = 3f; void Update(){ //rotate to look at the player ...


0

At first glance, it looks like you have the algorithm correct. The part that jumps out as possibly wrong is this: if(maxScore == 0){ bestMove = moves[rand.nextInt(moves.length)]; } maxScore of 0 means that the best move the AI can make will lead to no change in the relative number of pieces per player (assuming both sides continue to play correctly). ...


1

This function appear strange because it does not actually compute force, it compute the delta in velocity (the change in velocity) which is needed in order for the agent to turn and pursue the target. It has nothing to do with force and mass and yet those are artificially squeezed in there for no reason. If you want gradual change, compute the desired ...


1

That function gives you a direction scaled such that it indeed performs an instantaneous velocity fix, if added to your velocity. You can think of this as the "steer direction". You can scale this direction by whatever factor you like. Maybe something like this to get started: const dt = (1.0 / 60.0); object.velocity += dt * object.Seek( targetPosition ); ...


2

One last thing is that if you are using the Object Pool pattern and an entity gets reset because the creature died (for instance) and respawned somewhere else, a reference will still point to the same entity (fault) and an ID will no longer remain valid. ID 5067 points to address 0x8765 creature dies and another spawns new creature ID is reset to 7073 ...


15

References work well for many situations. However, there are three important situations in which references won't work well: Networking. When sending information about synchronizing the state of entities over the network, references can't be used. You'll need to identify the entity in some way so the remote machines know who you're talking about. ...


10

There are two ways an AI controlled unit with a bound rotation speed and an adjustable movement speed could reach a goal. First, lets consider the challenge we are presented with so we could understand it better: If the player is moving and rotating in constant speeds while trying to reach a goal that is on its right or left side, it will move in circles ...


2

You could treat the turret as stationary and subtract the velocity of the turret to the target's velocity before the start of the code, provided it works for a motionless turret. To subtract velocity vectors, if the target is moving 4 pixels left and 8 pixels up in a given time, but the turret is moving 4 pixels right and 3 pixels up in the same time, the ...


1

Here is how I would approach this: I would start by performing terrain analysis (pdf) and creating a set of influence maps based on various attributes (conflict maps, resource maps, etc). You might want to combine the influence maps together with associated weights. You'll probably update some of them at the start of each turn. But assuming you have the ...


1

I have no experience programming AI. However, I can offer you my naive strategy that might help you brainstorm a little. I know you said you'd prefer experienced individuals for this question, but this is an intimidating question to say the least. Right then. What I would do is implement a per-turn checklist/surveillance. Each AI unit, every turn, would: ...



Top 50 recent answers are included