Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Now my 3D model has complete AI behaviours, but my model has no collision avoidance while he is moving towards the player! Because of this, he gets stuck in front of 3D blocks sometimes.

I think the solution includes the usage of rays. I've included a picture of what I want to do.

NOTE: The world is a 3D world, not a 2D one. (Even though they are almost the same)

I want my model to not collide with the boxes while he is moving towards me, i.e make some collision avoidance. :)

enter image description here

share|improve this question
Aren't you looking for pathfinding? – Grey May 27 '13 at 23:13
Code Assassin , I want my model while is moving toward me ( seek ) just not collide with the models , i.e make some collision avoidance :) – Mohammad Ahmed May 27 '13 at 23:14
So he's just continually finding a path to you – ssb May 27 '13 at 23:28
@ssb, yes!! i think you know more than me what do you think – Mohammad Ahmed May 28 '13 at 21:38
@ssb , I just want to avoid 3d models ( house , rock , mountine .....etc ) while enemy moving toward me I just want him to not get stuck in the way – Mohammad Ahmed May 28 '13 at 21:43

A couple people have mentioned pathfinding, but that's only necessary for complex paths, like navigating a maze. Your situation just calls for basic obstacle avoidance so full fledged pathfinding is overkill (plus you often need obstacle avoidance in addition when doing pathfinding anyway). Look on this page for some great examples of steering behavior:

In the list of demos you'll notice "Obstacle Avoidance". All you need to do is that, plus make your AI tend to turn toward the player when no obstacle is in the way. The site may have sample code to look at, but simply reading the description is probably gonna help you the most

In essence all it's doing is a box intersection check ahead of the moving entity (a raycast with a wide radius would do too) and if another object is intersected then the entity turns.

share|improve this answer
This steering and obstacle avoidance is all you need ! – Vishnu May 28 '13 at 5:35
Only if assuming the domain has very specific traits. This is difficult to ascertain based only on the phrasing of the question. – Attackfarm May 28 '13 at 7:02
The phrasing sure, but that's why he included a diagram. The diagram makes it pretty clear what kind of obstacles he's talking about. – jhocking May 28 '13 at 12:52
@jhocking , thanks brother I think you know what I mean , I just need to avoid houses while enemy moving toward me not more. – Mohammad Ahmed May 28 '13 at 21:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.