Profile image

[XML tutourial] How to make AI convoi trucks that follow you?

88.7k winterro  2.0 years ago

So for the people that might be out there who ask themselves how to make your own convoi that follows you, you have came to the right place!

Engine

alt+ text

When coding the engine, you need to do two things:
1. Set the input to throttle
2. enter the code in the activationgroup clamp01((TargetDistance > 22) - (TargetDistance >9999999999))

Airbrake

The airbrake is important to brake the car, so it doesn't ram you.

alt text

Step 1. put the code Activate8 into the input section
Step 2. put the code clamp01((TargetDistance > 0) - (TargetDistance >22)) into the activationGroup section.

Auto steering

This is the part that makes the car go after you.

alt text

Step 1. put 0.1 into max and put -0.1 into min
Step 2. put clamp(deltaangle(0,atan(((sin((RollAngle + 0)) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + cos((RollAngle + 0)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + cos(-PitchAngle) * (-sin((RollAngle + 0))) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))))) - ((pingpong(Time*1000,1) - 0.5))) / ((cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))))) - ((pingpong(Time*1000,1) - 0.5)))) + ((((cos(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))))) - ((pingpong(Time*1000,1) - 0.5))) < 0) ? ((((sin((RollAngle + 0)) * sin(-PitchAngle) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * cos((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + cos((RollAngle + 0)) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * sin(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))) * sin((TargetHeading - Heading + rate(TargetHeading) * TargetDistance/1000))) + cos(-PitchAngle) * (-sin((RollAngle + 0))) * ((TargetDistance + rate(TargetDistance) * TargetDistance/1000) * cos(((TargetElevation + 90 + rate(TargetElevation) * TargetDistance/1000) + (asin((cos(TargetElevation + (rate(TargetElevation)) * TargetDistance/1000) * (TargetDistance + rate(TargetDistance)*TargetDistance/1000) * 9.81)/(1000 * 1000))/2))))) - ((pingpong(Time*1000,1) - 0.5)))>0) ? 180 : -180) : 0)),-25,25) into the Input section

If you have all the steps correct, it should work correctly.

Any questions about it in the comments

  • Log in to leave a comment
  • Profile image
    88.7k winterro

    here is the truck, if the steering code doesnt work, i think it might help XD Ai truck (Zis-5)

    Pinned 2.0 years ago
  • Profile image
    88.7k winterro

    It seems the code, is a bit too long for the steering XD
    putting it into the comments doesnt work, becouse it exeeds the 4000 character limit, imma post a link to the truck in a pinned comment soon

    Pinned 2.0 years ago
  • Profile image
    60 Tahytn

    Can he make one of these for planes?

    26 days ago
  • Profile image
    23.0k soldier289

    This is pretty awesome.

    1.9 years ago
  • Profile image
    2,881 FaLLin1

    @winterro thank you sir

    2.0 years ago
  • Profile image
    29.5k xNotDumb

    Cool!

    2.0 years ago
  • Profile image
    88.7k winterro

    @FaLLin1 yeah, it is possible, il figure that out for ya

    +2 2.0 years ago
  • Profile image
    2,881 FaLLin1

    is it possible for planes?

    +1 2.0 years ago
  • Profile image

    Thats pretty sweet, good innovation.

    2.0 years ago
  • Profile image
    11.5k JesusChrist

    Step 1: Code
    Step 2: Code
    Step 3: Codecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecodecode

    +1 2.0 years ago