Ok Here you have a longer description:
////// I copied this distance method from the example "Dark Dungeon"
float dist;
float getDistance ( float x1 , float y1 , float z1 , float x2 , float y2 , float z2)
{
float dist;
float dx;
float dy;
float dz;
dx = x2 - x1;
dy = y2 - y1;
dz = z2 - z1;
dist = sqrt ( ( dx * dx ) + ( dy * dy ) + ( dz * dz ) );
return dist;
}
//// Here starts the attacking function. It's written in a header and I call it in the mainloop.
void Attack ()
{
// 1000 is an enemy, 0 is the camera
dist = getDistance ( dbObjectPositionX ( 1000 ) , 0 , dbObjectPositionZ ( 1000 ) , dbCameraPositionX ( 0 ) , 0 , dbCameraPositionZ ( 0 ) );
if ( dist < 200 ) /// if the distance between the camera and the enemy (spider) is <200 the spider does this:
{
dbLoopObject (1000, 0, 5); //Walking animation of the enemy (animated with 3D Canvas Pro)
dbSetObjectSpeed ( 1000, 10 ); //Speed of the animation (Works correctly, the spider moves the legs in a speed wich looks natural)
///Until here all is OK
dbPointObject (1000, dbCameraPositionX (0), dbCameraPositionY (0) , dbCameraPositionZ (0) ); //Here the Spider is pointed at the current camera position.
dbMoveObject ( 1000, 1.0f ); //Here the spider should move to the camera, but this does not happen.
}
}
Now I tell you what happens, and what I ment with "dissapears and appears again":
I compile it, then I walk to the spider.
When I'm close enough the spider is in the air:
[img]undefined[/img]
When I'm walking while the spider is next to me it is flying around me in a circle.
It also has no collision to other Objects (It flies through stones and the terrain).
The thing with dissappearing and appearing has to do, I think, with the framrate:
// switch on sync rate and set to a maximum of 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
It appears and dissappears in this framerate for some seconds, then its away completely, until I start walking. Then it flies around me again.
I think I didn't understand what dbPointObject does, but with this definition my code should work (except collision):
Quote: "dbPointObject
This command will point the specified 3D object towards a point in 3D space. The command sets the current direction of the object to face towards this point in space."
Which code do you use for your enemies?
Thanks for your help so far
Regards
MES
http://www.Computer-Masters.de