Hi,
I know this has been talked about before and I read quite a bit about in forum but nothing seems to work.
What I have is:
1. I load my serialized objects (ground and quickly made robot, just a meshes with textures) and everything works fine
mesh_plaza = Loader.loadSerializedObject(res.openRawResource(R.raw.plaza4s));
mesh_plaza.setScale(30);
mesh_plaza.setTexture("text_plaza");
mesh_plaza.translate(0, -20, 0);
world.addObject(mesh_plaza);
mesh_plaza.strip();
mesh_robot = Loader.loadSerializedObject(res.openRawResource(R.raw.robots));
mesh_robot.setScale(20);
mesh_robot.setTexture("text_robot");
mesh_robot.translate(0, -35, 0);
mesh_robot.setName("airob");
mesh_robot.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
world.addObject(mesh_robot);
mesh_robot.strip();
2. In onTouchEvent I set moveSpeed and touchTurn variables (i use a dpad I made for it, so moveSpeed is between -2 and +2, 0 being center of my directional-pad)
3. In the onDrawFrame for turning: (that works GREAT, the robot turns on the it's Y axis)
if (touchTurn != 0) {
//world.getCamera().rotateY(touchTurn);
mesh_robot.rotateY(touchTurn);
}
4. Still in onDrawFrame, for moving I tried quite a few things and found in forum that using the object's getZAxis would give me its current directionto which then I just add to z (or x depending on how it was modeled):
if (moveSpeed != 0) {
SimpleVector robot_turn = mesh_robot.getZAxis();
mesh_robot.translate(robot_turn.x, robot_turn.y, robot_turn.z+moveSpeed);
}
But this gives some very weird results. First, without turning, the robot will go back and forth (his front is initially positioned on the Z axis) but once I start turning all hell breaks loose.
he will often just move sidewise-forward not only in one direction.
Any help or hint would be awesome.
Thank you
PS: next I am going to try to get the camera to follow, get the robot to not go through walls, add gravity so the robot can jump etc...so much to learn.