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.
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.
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.
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?
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.
see this, maybe is just a bit complex, but is the behaviour correct?
ah,well, the one of kevin should be more “friendly”
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])
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.