actually i tried that and I think I like the look at object option works better.
/*
Name: Example 25
Description: Box2D joints - part 2
*/
// include our main header file
#include "Main.h"
// let the compiler know we're using the AGK namespace
using namespace AGK;
// declare our app
app App;
int sphere1;
int sphere2;
int cylinder;
void app::Begin ( void )
{
sphere1=agk::CreateObjectSphere(.2,3,3);
sphere2=agk::CreateObjectSphere(.2,5,5);
agk::SetObjectPosition(sphere1,4,5,6);
agk::SetObjectPosition(sphere2,3,7,4);
cylinder=agk::CreateObjectCylinder(10,.2,5);
agk::SetObjectPosition(cylinder,4,5,6);
float x1=agk::GetObjectX(sphere1);
float y1=agk::GetObjectY(sphere1);
float z1=agk::GetObjectZ(sphere1);
float x2=agk::GetObjectX(sphere2);
float y2=agk::GetObjectY(sphere2);
float z2=agk::GetObjectZ(sphere2);
float anglez=90;
float anglex=90;
if((y2-y1)!=0)
{
anglez=agk::ATan((x2-x1)/(y2-y1));
}
if((z2-z1)!=0)
{
anglex=agk::ATan((y2-y1)/(z2-z1));
}
}
void app::Loop ( void )
{
// this function gets called on a continual basis, use this to update your
// game logic and deal with input and other events
float x1=agk::GetObjectX(sphere1);
float y1=agk::GetObjectY(sphere1);
float z1=agk::GetObjectZ(sphere1);
float x2=agk::GetObjectX(sphere2);
float y2=agk::GetObjectY(sphere2);
float z2=agk::GetObjectZ(sphere2);
agk::SetObjectLookAt(cylinder,x2,y2,z2,0);
for(int icnt=0;icnt<255;icnt++)
{
if(agk::GetRawKeyState(icnt)==1)
{
agk::Print(icnt);
}
}
if(agk::GetRawKeyState(37)==1)
{
agk::SetObjectPosition(sphere2,agk::GetObjectX(sphere2)+1,7,agk::GetObjectZ(sphere2));
// agk::SetObjectRotation(cylinder,agk::GetObjectAngleX(cylinder),agk::GetObjectAngleY(cylinder),agk::GetObjectAngleZ(cylinder)+1);
}
if(agk::GetRawKeyState(39)==1)
{
agk::SetObjectPosition(sphere2,agk::GetObjectX(sphere2)-1,7,agk::GetObjectZ(sphere2));
// agk::SetObjectRotation(cylinder,agk::GetObjectAngleX(cylinder),agk::GetObjectAngleY(cylinder)+1,agk::GetObjectAngleZ(cylinder));
}
if(agk::GetRawKeyState(38)==1)
{
agk::SetObjectPosition(sphere2,agk::GetObjectX(sphere2),7,agk::GetObjectZ(sphere2)+1);
// agk::SetObjectRotation(cylinder,agk::GetObjectAngleX(cylinder),agk::GetObjectAngleY(cylinder),agk::GetObjectAngleZ(cylinder)+1);
}
if(agk::GetRawKeyState(40)==1)
{
agk::SetObjectPosition(sphere2,agk::GetObjectX(sphere2),7,agk::GetObjectZ(sphere2)-1);
// agk::SetObjectRotation(cylinder,agk::GetObjectAngleX(cylinder),agk::GetObjectAngleY(cylinder),agk::GetObjectAngleZ(cylinder)+1);
}
agk::Print(agk::GetObjectAngleZ(cylinder));
agk::Print(agk::GetObjectAngleY(cylinder));
// we call agk::Sync to update the screen, when this happens our sprite
// will get drawn on screen
agk::Sync ( );
}
void app::End ( void )
{
// this function gets called when the game ends, in here you can clean up
// all resources and deal with things like saving game data
}
but it looks like the cylinder is not pointing to the next point. but it makes the correct angles at least
Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.