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


4

What you describe is a classic "pull" model of querying the world. Most of the time, this works pretty well, especially for games with basic AI (which is most). However, there are a couple of points you should consider that might be downsides: You probably want to double buffer. See game programming patterns on the subject. By always requesting the data ...


4

AI being costly, performance is often the driving factor in architecture. To ease your concerns around data access models, let's consider a few different AI examples both in- and outside of the games industry, working from that which is furthest from human navigation to that which is most familiar to us. (Each example assumes a single, global logic ...


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

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