3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: AI Control  (Read 1226 times)

« on: December 23, 2012, 01:02:03 PM »
Hi.
I made Racing game with 3drad, But I have a problem with cars speed. I want Know what is best setting for CarAI that driving vehicle? what is Best Speed for cars that when you're behind the opponent's car, can able to reach or when you're ahead of the car's opponent, can Be close to you?
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #1 on: December 23, 2012, 01:05:35 PM »
Maybe have it just over your speed, then when it turns, it will lose
some of its speed, allowing you to catch up.
Otherwise you would need a script to increase the speed
when behind your car, and decrease it when you are behind it.
« Reply #2 on: December 23, 2012, 10:18:49 PM »
Quote
Otherwise you would need a script to increase the speed
when behind your car, and decrease it when you are behind it.

I've already used this script, But dosn't work well.

Code: [Select]
float CarSpeed;
void Main()
{
   IN_0=CarSpeed;
   if (IN_22==1)
   if (CarSpeed>IN_44) {
   OUT_48=4;
   OUT_4=1.7;
}
   else if (IN_22!=1)
   if (IN_44>CarSpeed) OUT_48=1.5;
}

Quote
Information:
IN_0=Car Player Speed
IN_22=Standing
OUT_48=Car Enemy Acceleration
OUT_4=Car Player Acceleration
IN_44=Car Enemy Speed
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #3 on: December 30, 2012, 01:03:40 PM »
Can someone help me to solve this problem?
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.

fourdee

« Reply #4 on: December 30, 2012, 08:17:59 PM »
Can someone help me to solve this problem?

Not sure if this is right, havnt tested it, however, you should be able to pull a working script from it.

I noticed in your script you used IN_0=CarSpeed. It needs to be the other way round CarSpeed=IN_0 , as you are defining CarSpeed from an input.

Code: [Select]
float CarSpeed;
float CarSpeed_ai;
float PlayerPosition;
void Main()
{
   CarSpeed=IN_0;
   CarSpeed_ai=IN_44;
   PlayerPosition=IN_22;

   if(PlayerPosition == 1) // if player is 1st - speed AI up
   {
       OUT_48 = 2; //Car Enemy Acceleration
       OUT_4 = 1; //Car Player Acceleration
   }
   else // Slow AI down
   {
       OUT_48 = 0.5; //Car Enemy Acceleration
       OUT_4 = 1; //Car Player Acceleration
   }

}
« Reply #5 on: January 01, 2013, 01:17:44 AM »
Thanks Fourdee, But I've already write a script like this, But dosn't work well. I think we need to be more complicated than. this.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #6 on: January 01, 2013, 09:09:55 AM »
Set the car speed a bit Easter than yours, then if it goes behind you, get it to go faster until it over takes you. Why won't that work?

fourdee

« Reply #7 on: January 02, 2013, 04:43:30 AM »
Thanks Fourdee, But I've already write a script like this, But dosn't work well. I think we need to be more complicated than. this.

Things dont need to be complicated. Start simple, make sure it works, then you can add to it.

Your original script will not work because its logic is wrong
Code: [Select]
float CarSpeed;
void Main()
{
   IN_0=CarSpeed;
   if (IN_22==1)
   if (CarSpeed>IN_44) {
   OUT_48=4;
   OUT_4=1.7;
}
   else if (IN_22!=1)
   if (IN_44>CarSpeed) OUT_48=1.5;
}
IN_0=CarSpeed should be CarSpeed=IN_0

if (IN_22==1) if (CarSpeed>IN_44)  should be if(IN_22 == 1 && CarSpeed >= IN_14){do this;}

Honestly, i think if you tried my script, it should allow you to start "simple" but "functioning" :)

secondry2

« Reply #8 on: January 02, 2013, 04:26:22 PM »
Ummmmm maybe stating the obvious, but this goes in the tech discussion doesn't it ???
« Reply #9 on: January 03, 2013, 01:52:43 AM »
Thanks Fourdee  ;D
I think you're right, My Script the logic is wrong, and now work very well.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
Pages: [1]