Game Development Community

AIPlayer <> But NOT simple Rotation

by Andrea Barolo · in General Discussion · 07/31/2006 (7:52 am) · 5 replies

Hello to everybody !!
Im trying to make space ship fight with ai controlled spaceship BOTs.

To make this I need basic routines for the AI. For example Forward 1/3 - Turn bearing "1 8 0" and so on !!



Im completelly stuck on imlementation of setDirection(30)

I created correctly the consolle function, but now I cannot understand If I have to modify gatAiMove function or if there is a simpler way to create it !!

In short , I need a consolle function in wich, if I insert the bearing, the AIplayer turns correctly and than stops accordingly to the given angle !!!

If some one can hale me , thank you !!!

#2
08/02/2006 (6:14 am)
WOW !! thank you !! Mut in the meanTime I solved it myself ;)
I modified the AIPlayer::getAIMove(..)

function with this simple code !!
if(mTurn){
			

	F32 currAngle = getTransform().toEuler().z;
	F32 angl = (mTAngle * M_2PI)/360;

	 if(mTAngle>0)
	   movePtr->yaw = 5.0;
        	 else
	   movePtr->yaw = -5.0;

			 
	
	 F32 angDiff = abs(angl - currAngle);
			
	 if(angDiff <=0.1)
			{
				mTurn = false;
				mTAngle = 0.0;
				movePtr->yaw = 0.0;
			}
			 
		 }
	//Edo ---- fine funzione aggiunta

with mTurn -> a boolean set to true when the consolle function setDirection(angle) is called from script.
Than mTAngle an F32 angle passed from the consolle function !!!
I have to fix the turn direction so the ship turns to the short angle, but Ill do shortly !! ;)

Thankz again
#3
08/02/2006 (10:58 am)
Say, just so you know... you are not allowed to post code snippets from the engine in public. You might want to delete that code block in your post.
#4
08/02/2006 (12:23 pm)
Would have to be pretty anal to reprimand him for that code block..
no trade secrets.. nothing fancy.

his only access to private code is the yaw member and the getTransform call..
hardly private.

But a good tip none the less Cliff.
I'm just saying I think we can let this one go.
#5
08/03/2006 (4:44 am)
Aaaaaaaaaaaaaa gghhhhh !!!! Im very sorry !!!!! Can one moderator move this post to the right location ???

In the future this will not happen again !!!