17

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


15

Give your agents a weak "electrostatic charge" to make them repel each other, along the lines of Coulomb's law. Assuming for simplicity that mobs should push each other away with equivalent strength, it should be enough to apply a force between every pair of mobs with a magnitude some_constant / distance^2, where some_constant is a configurable repulsion ...


8

What you have to do is estimate the future position of the moving target and steer towards that. Here is bobobobo's super 5 step simplified process 1. Initial picture of the system. 2. Really what we are doing here is subtracting the rocket's velocity from both bodies in the system, so the rocket is effectively "stationary", and the target is moving 3. ...


6

I'm going to assume that the rotation of the engine is purely visual, and the acceleration during any thrust is in a constant direction. (If we're accelerating in a rotating direction, the math for planning the trajectory gets a LOT more complicated very quickly, so I'd recommend turning off the thruster when turning, and just accounting for that as a linear ...


5

Just clip the maximum allowable rotation angle of the heading vector for the agent to something like 5 degrees/frame. (ie the red vector in your diagrams). Right now your agents kind of have this omnidirectional capability to steer. You need to change that. To get the agent to behave more like a car, an agent should only be able accelerate in the FORWARD ...


4

Since your AI is steering based it's pretty simple. You need to weigh your forces based on how important they are. The closer you get to obstacles the more important they should be, otherwise chasing should be the most important. There are a couple different ways to implement it, but I always found having some "max force" worked best where you iterate over ...


4

This is a pretty interesting question, and i'm going to try to contribute with what I can. First, I think you have to clearly define the boundaries for the game you are trying to create, and define those questions (some may already been answered). How far the is the monster aggro ? How many monsters at the same time is your target? How is your terrain ...


4

Instead of laying your approach vector on the line connecting the target to the current position, lay it along one of the tangents to the desired orbit from the current position. Than make just a speed change at the point of tangency. This is actually quite similar to how real orbital mechanics is performed, so should feel quite natural in addition to being ...


3

As a mechanical engineer whose also interested in game development I appreciate how difficult this problem can become; anything more than the naive solution I am about to describe requires a sound understanding of control systems. Simple Solution I am developing a 2d game where players have control over a spaceship (approach should work just as well for AI ...


3

The easiest way to do this seems to be to simply generate a random point on the mesh and walk to it. You can restrict the point to be within a radius of the monster's position in order to avoid really long random walks too.


3

There is no 'best' solution to this problem. Ultimately you're going to have to find by trial and error something that gives the best tradeoff between performance and believable intelligence. However if you want to use any sort of path finding algorithm you're going to need to subdivide your world in some way. Whether you go with tiles, polygonal zoning or ...


3

I solved the problem. Now script work fine. Just drop this script on game object and enjoy. using UnityEngine; public class UnitWander : MonoBehaviour { public float CircleRadius = 1; public float TurnChance = 0.05f; public float MaxRadius = 5; public float Mass = 15; public float MaxSpeed = 3; public float MaxForce = 15; ...


3

While a bit different to your example above, I have implemented a spring algorithm into my game that has worked for me. The idea is that if the object comes close at a certain determined buffer distance to another object, a magic invisible spring appears and corrects the path of the object(s). Here is a video recording of my game engine demonstration ...


3

Yes, we can do better. We need a maximun steering per unit of time. // get the steering direction steering = desired_velocity - velocity // ensure the steering never exceeds our maximum steering per unit of time steering = truncate(steering, max_steering * delta_time) // ensure the velocity never exceeds the max speed velocity = truncate (velocity + ...


2

if (degrees < 45 && degrees > -45) direction = vector(1.0, 0.0); else if (degrees == 45.f) direction = vector(1.0, 1.0); else if (degrees > 45 && degrees < 135) direction = vector(0.0, 1.0); else if (degrees == 135.f) direction = vector(-1.0, 1.0); ...


2

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 good solution is to send 2 rays from the upper and lower bound of the object rather then in the middle. You can then use the algorithm you were using before but use collisions for both rays rather then one. Don't forget to set the direction to the correct value of only one ray hits something (that is away from that ray). If both rays hit an object just ...


2

A fix was made upstream related to your solution that resets the desired velocity in resetMoveTarget. bool dtCrowd::resetMoveTarget(const int idx) { if (idx < 0 || idx >= m_maxAgents) return false; dtCrowdAgent* ag = &m_agents[idx]; // Initialize request. ag->targetRef = 0; dtVset(ag->targetPos, 0,0,0); ...


2

You will have to calculate the desired input (steering and throttle) based on: The relative direction of the desired velocity when compared to the current velocity (for steering input) The relative magnitude of the desired velocity when compared to the current velocity (for throttle input) For calculating steering input, we need to calculate the amount of ...


2

The easiest way is probably using an exponential filter: float target_height = 0.0f; float current_height = 100.0f; float smoothness = 0.95f; void update() { current_height = smoothness * current_height + (1.0f - smoothness) * target_height; } Notice that this is non-physical. If you must make use of physics, you can do this using a ...


2

Give your mage a movement direction vector. When mage moves, turn it around slowly - this will give you wiggling movement. If mage goes outside of allowed range, or gets close to it, turn direction vector towards the center. If it gets too close, turn it away from center. Depending on how fast and how often you change direction vector, you may get the loops ...


2

If you are using steering behaviors to guide your objects, you could add a repellant force in the center of the circle. A repellant force is a vector that points in the direction from the center of the circle to the object. The length of the vector is in inverse relation to the distance of the object from the cente (closer: bigger force, distant near zero ...


2

First let me preface this by saying, I think there's a better way to approach this problem by using a different metric (i.e. something like using polar coordinates rather than euclidean X,Y coordinates). That said, using standard X,Y coords, the easiest way I can see to approach this problem is a test and reject pattern: Randomly generate a potential new ...


1

When acceleration a is constant, use the High School kinematics equations: v = u + a t delta-d = u t + a t ^2 / 2 v^2 - u^2 = 2 d (delta-d) delta-d = (v + u) / 2 t where: u is the unitial velocity (sic) v is the vinal velocity (sic) t is the elapsed time delta-d is the displacement from starting position to ending position.


1

For a very minimalistic car you won't need anything other than two values: velocity and direction. Both values can be just a floating point number. When steering left/right, adjust the direction, which could be as simple as being the angle the car is facing. Accelerating or breaking will modify the velocity. if (key_left) direction -= 0.001; else if (...


1

If you want it to be a realistic representation of an intelligent agent avoiding an obstacle, then I would suggest a different (more representative and general) kind of model. When the agent first enters the situation, have it plot a course to the target, and check whether the course will crash into anything or not. If not, then it can follow that plan ...


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