plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

We prepared 3 new YouTube tutorials about Audio! They are available here.
You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

Please take a moment to read the platform’s guidelines before you get started!


question

Sasa avatar image
Sasa asked Sasa commented

Is there a way to have simobjects avoiding collisions with each other?

Hello!

I'm using Mission file scripts (https://docs.flightsimulator.com/html/index.htm#t=Content_Configuration%2FFlights_And_Missions%2FMission_Definitions.htm) to create custom ground traffic around an airport. Traffic that is not connected to gate services around the gates but rather ground traffic like buses, landside cars, animals etc. (haven't checked but I think the problem described applies to services also).

Is there a way to have them yield to each other and avoid collisions? Sadly they always run though each other.

The "YieldToUser" tag doesn't work here as this only applies to user aircraft but not AI objects to each other. Works fine yielding to aircraft, but creates the problem that when 2 or more simobjects yield for user aircraft following the same path, they will always collide with each other (or rather "merging into each other") instead of the 2nd one stopping a few meters behind the 1st one yielding the aircraft.

Another idea was to possibly use something like a <SimMission.ProximityTrigger> but this one isn't documented yet (see link above), so I don't know if this would be the right approach.


Thanks!

scenerymission
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

1 Answer

·
Mr_LiamT avatar image
Mr_LiamT answered Sasa commented

How do you have you simobject set up? Maybe try setting the AIType to GroundVehicle. Or try setting up your simobject like ASO_TruckUtility01

3 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

As far as I can see it is exactly set up same same way as ASO_TruckUtility01 and is also set to AIType=GroundVehicle. Here's the content of the applicable files:


Model XML (LS_VH_Anim_005.xml) of simobject:

<?xml version="1.0" encoding="UTF-8"?>
<ModelInfo version="1.1" guid="{2bf41647-97b1-4482-a887-814e10ce25df}">
<LODS>
       <LOD minSize="1" modelFile="LS_VH_Anim_005.gltf"/>
</LODS>
<Animation name="LS_VH_Anim_005_Rotation" guid="804336d3-ea56-44c4-a973-129ad80c4ff9" type="Standard"/>
<Animation name="LS_VH_Anim_005_Orientation" guid="3f80b3f2-321f-4c27-9cfd-a08e109022bc" type="Standard"/>

<Behaviors>
<Include ModelBehaviorFile="Asobo\Misc\GroundVehicles.xml"/>

<Component ID="Wheels">
<UseTemplate Name="ASOBO_Wheel_Roll">
<ANIM_NAME>LS_VH_Anim_005_Rotation</ANIM_NAME>
<WHEEL_RADIUS>0.31</WHEEL_RADIUS> <!-- in meters -->
</UseTemplate>

<UseTemplate Name="ASOBO_Wheel_Turn">
<ANIM_NAME>LS_VH_Anim_005_Orientation</ANIM_NAME>
<ORDER_MULTIPLIER>-1</ORDER_MULTIPLIER> <!-- 1 if first frame of animation is turning left, -1 if turning right -->
<PERCENT_PER_SECOND>50</PERCENT_PER_SECOND> <!-- speed of the anim in percent per second. 100 means from max left to max right in 1 second -->
</UseTemplate>

</Component>

<Component ID="Lights">

<UseTemplate Name="ASOBO_GroundVehicle_HeadLights"/>
<UseTemplate Name="ASOBO_GroundVehicle_BackLights"/>

</Component>

</Behaviors>
</ModelInfo>


sim.cfg:

[VERSION]
Major=1
Minor=0

[fltsim.0]
title=LS_VH_Anim_005
model=""
texture=""

[General]
category=GroundVehicle
DistanceToNotAnimate=2000

[PILOT]
pilot_default_animation = "Driving_GPU"
pilot_attach_node = "PILOT_0"

[contact_points]
wheel_radius=3.15
static_pitch=0.0                ;degrees, pitch when at rest on the ground (+=Up, -=Dn)
static_cg_height=0              ;feet, altitude of CG when at rest on the ground

[DesignSpecs]
max_speed_mph = 50     
acceleration_constants = 0.3, 0.4     ;Time constant (effects responsiveness), and max G acceleration
deceleration_constants = 0.2, 0.4     ;Time constant (effects responsiveness), and max G acceleration
turning_constants = 2.0, 45, 4.0, 15.0 ;Time constant (effects responsiveness), max deg/s acceleration, optimal (knots) turning speed, max (knots) turning speed


[WAYPOINT]
StopDistance = 0.6

[TAXI]
DistanceToLaneLine = 2.0

[LIGHTS]
newlight.0 = HeadLight, Headlight_R, Headlight_Mesh, Headlight_Emi
newlight.1 = HeadLight, Headlight_L, Headlight_Mesh, Headlight_Emi
newlight.6 = BackLight, BackLight_R, Backlight_Mesh, Backlight_Emi
newlight.7 = BackLight, BackLight_L, Backlight_Mesh, Backlight_Emi


LS_AI_Landside.xml (SPB source XML calling above simobject in 2 instances following the same path in opposite direction - you will see that they don't avoid each other):

<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="MissionFile" version="1,0">
    <Filename>LS_AI_Landside.xml</Filename>
    <WorldBase.Flight>



        <SimContain.Container InstanceId="{ade0923a-2187-46e3-b3e6-796f73624005}"><!-- Unique GUID -->
            <Descr>none</Descr>
            <ContainerTitle>LS_VH_Anim_005</ContainerTitle><!-- SimObject name -->
            <IsOnGround>True</IsOnGround>
            <LocalOffsetXYZ>0.000,0.000,0.000,0.000</LocalOffsetXYZ><!-- SimObject spawn offset -->
            <LocalOrientation>0.000,0.000,0.000</LocalOrientation>
<AIType>GroundVehicle</AIType>
            <ContainerID>-1</ContainerID>
            <SimplifiedSimMode>AI</SimplifiedSimMode>
            <ParameterAI>
                <GroundCruiseSpeed>6.000</GroundCruiseSpeed><!-- Speed in KNOTS -->
                <GroundTurnSpeed>3.000</GroundTurnSpeed>
                <GroundTurnTime>4.000</GroundTurnTime><!-- 90° turns in this amount of seconds -->
                <YieldToUser>True</YieldToUser>
                <CanReverse>False</CanReverse>
                <KeepLastHeading>True</KeepLastHeading>
                <WaypointList>
                    <WrapWaypoints>True</WrapWaypoints>
                    <CurrentWaypoint>0</CurrentWaypoint>
                    <BackupToFirst>False</BackupToFirst>
                    <AlwaysBackUp>False</AlwaysBackUp>
                    <YieldToUser>True</YieldToUser>
                    <Waypoint InstanceId="{aaae5899-9306-490c-9ed7-dc06501b5005}"><!-- Unique GUID -->
                        <Descr>Waypoint 001</Descr>
                        <WaypointID>001</WaypointID>
                        <LocalOffsetXYZ>0.000,0.000,0.000,0.000</LocalOffsetXYZ>
                        <AltitudeIsAGL>True</AltitudeIsAGL>
                        <IsTeleportEnable>False</IsTeleportEnable>
                    </Waypoint>
                    <Waypoint InstanceId="{acd3bcbe-4c4f-4630-94fb-1424e8d01005}"><!-- Unique GUID -->
                        <Descr>Waypoint 002</Descr>
                        <WaypointID>002</WaypointID>
                        <LocalOffsetXYZ>100.000,0.000,0.000,0.000</LocalOffsetXYZ>
                        <AltitudeIsAGL>True</AltitudeIsAGL>
                        <IsTeleportEnable>False</IsTeleportEnable>
                    </Waypoint>
                </WaypointList>
            </ParameterAI>
        </SimContain.Container>



        <SimContain.Container InstanceId="{aec0923a-2187-46e3-b3e6-796f73624008}"><!-- Unique GUID -->
            <Descr>none</Descr>
            <ContainerTitle>LS_VH_Anim_008</ContainerTitle><!-- SimObject name -->
            <IsOnGround>True</IsOnGround>
            <LocalOffsetXYZ>100.000,0.000,0.000,0.000</LocalOffsetXYZ><!-- SimObject spawn offset -->
            <LocalOrientation>0.000,0.000,0.000</LocalOrientation>
<AIType>GroundVehicle</AIType>
            <ContainerID>-1</ContainerID>
            <SimplifiedSimMode>AI</SimplifiedSimMode>
            <ParameterAI>
                <GroundCruiseSpeed>6.000</GroundCruiseSpeed><!-- Speed in KNOTS -->
                <GroundTurnSpeed>3.000</GroundTurnSpeed>
                <GroundTurnTime>4.000</GroundTurnTime><!-- 90° turns in this amount of seconds -->
                <YieldToUser>True</YieldToUser>
                <CanReverse>False</CanReverse>
                <KeepLastHeading>True</KeepLastHeading>
                <WaypointList>
                    <WrapWaypoints>True</WrapWaypoints>
                    <CurrentWaypoint>0</CurrentWaypoint>
                    <BackupToFirst>False</BackupToFirst>
                    <AlwaysBackUp>False</AlwaysBackUp>
                    <YieldToUser>True</YieldToUser>
                    <Waypoint InstanceId="{0ace5899-9306-490c-9ed7-dc06501b5008}"><!-- Unique GUID -->
                        <Descr>Waypoint 001</Descr>
                        <WaypointID>001</WaypointID>
                        <LocalOffsetXYZ>100.000,0.000,0.000,0.000</LocalOffsetXYZ>
                        <AltitudeIsAGL>True</AltitudeIsAGL>
                        <IsTeleportEnable>False</IsTeleportEnable>
                    </Waypoint>
                    <Waypoint InstanceId="{0ab3bcbe-4c4f-4630-94fb-1424e8d01008}"><!-- Unique GUID -->
                        <Descr>Waypoint 002</Descr>
                        <WaypointID>002</WaypointID>
                        <LocalOffsetXYZ>0.000,0.000,0.000,0.000</LocalOffsetXYZ>
                        <AltitudeIsAGL>True</AltitudeIsAGL>
                        <IsTeleportEnable>False</IsTeleportEnable>
                    </Waypoint>
                </WaypointList>
            </ParameterAI>
        </SimContain.Container>

    </WorldBase.Flight>
</SimBase.Document>
0 Likes 0 ·

I still have to explore simobjects in the SDK, so I am not 100% sure how to get this to work.

Some things to try in LS_AI_Landside.xml :

Add a ground vehicle pilot to the containers:

            <AddPilot>
                <AIType>GroundVehicle_Pilot</AIType>
            </AddPilot>

Set the AI to taxi mode:

            <ParameterAI>
                <Unit_Mode>Taxi</Unit_Mode>
                ...
            </ParameterAI>


You can debug simobjects in the devmode with Options>Simobjects>GROUND_VEHICLE There you can look at the state of the AI and the path it wants to take.

As for the proximity trigger, you could use a trigger area that moves along with the simobject and detects any objects close to it, but I don't now how you can get the simobject to stop when the trigger fires, except for just de-activating the simobject entirely. You can find documentation for the proximityTrigger and more script elements on the FSDeveloper Wiki. I am still working on it and it is not complete, but hopefully it can help you. You can also add to the wiki if you find something out that is not yet documented.


0 Likes 0 ·

Adding a GroundVehicle_Pilot didn't have any effect at all.

Adding <Unit_Mode>Taxi</Unit_Mode> causes the waypoint following to halt at the very beginning.

I need to look into the proximity trigger but I already have a hard time using it for vehicles to stop when they reach a certain static rectangle (sometimes works, sometimes the animation just stops at random somewhere).

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.