Tag Info

Hot answers tagged

16

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

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 ...


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

How close to an edge do we care about? For a fairly thin threshold, avoiding the edges is quite closely approximated by finding the closest point on the edge and avoiding that: For a thick threshold, it's a good approximation to just steer toward the center of the screen:


1

First thing first, creatures should not avoid the "edges of the screen" because that is part of the View and not the actual Game Model. Game Entities should interact with the Game Model and not the View. The view is only the way you present the game to your game's players eyes. Secondly, what you are asking of has little to do with Obstacle Avoidance ...


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 ); ...


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: ...


1

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 ...



Only top voted, non community-wiki answers of a minimum length are eligible