How to make a grid game in Blender 2.6?

I am trying to create a simple grid game based on logic bricks where the player programs a robot to do certain actions (Move forward, move left, move up, move back, etc.) and then runs the program to complete the level. However, I am having difficulty getting the robot to move so that it stays directly on top of the grid floor design of the levels. If anyone could tell me how this can be done, I would appreciate it.

Here is an image of the level setup:


the logic described not seem that need of physic (that instead will just be a problem)
if not already try using a object robot STATIC(physic tab) and use motion loc/rot (rather than force,velocity…)

I suppose that could work, except I don’t think it would be efficient to animate the robot moving to every block in the game. Is there a way to make it move forward a bit then snap to the grid?

With python.
I suppose you meant by logic brick game a game that lets the user use logic bricks not that you restrict yourself to logic bricks?
Just floor/int the position of the object.

Also, what you mean by animate?
Loc/rot in motion actuator in logic brick has nothing to do with animation…

Actually it might be easier with logic bricks.
Add an empty object to the scene, then add to the robot a steering actuator set to target the empty object. Now when the robot has to move, you move the empty object to the center of the destination cell in the grid (the nearest one to the robot), then activate the steering actuator. The robot will then gracefully step into the next cell, stopping when it reaches the center.

Ok, thanks. I’ll try it.

Hmm… this brings me back to my original problem: How to make an object move on a grid? Would it be possible to place an empty object in each square and have the robot target a certain one depending on the logic brick program the player creates?
I would, if possible, like to program this game using only logic bricks. I do know some Python, but I’ve never quite figured out how to use it with Blender.

Heres an example file: GridMovement.blend (502 KB)

layer one has the object ‘jump’ to the next location, and on layer 2 is an example using the steering actuator, both use WASD to move.

I was about to answer too. I think what pgi said is something like that:

http://www.pasteall.org/blend/34026

Ok, the steering actuator is what I want to use. However, I can’t figure out the purpose of the “navmesh”. I have one in the scene now, but when I try to set it as the navmesh in the steering actuator, it won’t be selected, and the box remains blank. Do I really need a navmesh?

Well with some python you could get rid of the need for it. How did you make the nav mesh? How I made it in my file is this:

  1. select the ground mesh.
  2. hit the spacebar and type “Create Navigation Mesh”.
  3. select the “Create Navigation Mesh” from the list.
  4. You should now have a navmesh you can use in in the steering actuator.

Also, how can I make the target object not be able to move through walls?

Ok, but what is the navmesh for? Mine is a simple plane.

The navmesh is used so that the Cube can figure out where the target is. To stop the target from going through walls you can use the ray sensor to check for walls.

Heres an example: GridMovementEx2.blend (491 KB)

see this, maybe is just a bit complex, but is the behaviour correct?

ah,well, the one of kevin should be more “friendly” :wink:
maybe increase a bit the distance solve the “vibrations”

PS: there a bug in my file:
change this (line 10)
return bool(own.rayCast(rayend, own, 0.0, “wall”)[0])
with this
return bool(own.rayCast(rayend, own, 0.0, “wall”,1, 1)[0])

Attachments

robot_grid.blend (93.5 KB)

@@AVR_ENTERTAINMENT: In my example there was no navmesh. No need to have a navmesh in such situations…

I set my scene up exactly like you did, but the ray sensor is not detecting the wall. Also, my robot refuses to follow the target object, and if I try to tell it what the navmesh is, it rejects it. I have checked, double-checked, triple, and there are no differences in the logic bricks of your file and mine. I tried to upload the .blend file, but it won’t upload… Also, I don’t know if this makes any difference, but my current Blender version is 2.68.

EDIT: The robot follows the target object now, but the ray sensor still won’t work… When I turn off the “invert” button on the target object, it no longer moves, though.

Try taking a screenshot of your logic setup and post that maybe we can help then. Also did you put a property called “Wall” on your walls?

Yes, I put a Wall property on them. Here is the screenshot: