Does anyone have any examples of SimConnect AICreateSimulatedObject working

Looking for anyone that has successfully got SimObject Function - SimConnect_AICreateSimulatedObject to work. I get an SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE return with a objectID - however my simobject does not show up. SDK 0.8.0

The SDK blog update suggested that this is working now. But not for me.

I can get the function to run, and I see the object description in game but I cannot see the object. Such a bummer that there are no technical resources.

1 Like

Exactly the same here, tried everything (using SDK 0.8.0)

It is now working fine here (SDK 0.9.0.0 and MSFS 1.12.13.0). There is still something wrong with SimConnect_AIReleaseControl not always working, but I can live with this.

1 Like

I can confirm it works as well. What I cannot do is have the ai aircraft fly to a waypoint. Anyone play with that yet? I create the AI aircraft and it just does it’s own thing. Tried setting “AI WAYPOINT LIST” to no avail.

I tried this (waypoints) with a ground vehicle and worked fine. Don’t know if with an aircraft will be the same. I suggest to follow the “AI Objects and Waypoints” sample from older FSX SDK.

I got it to work with aircraft. I had to spawn them on the ground first though.

Got it working also.

Has anyone got waypoints to work with aircraft after using SimConnect_AICreateNonATCAircraft to create the aircraft? I tried with them on both the ground and in air, but when i send a Waypoint via a set data call for AI WAYPOINT LIST - the function returns true with no error - but the waypoint doesn’t take effect.

If i check the object via the simobject viewer it just says its still in Zombie mode and just keeps flying at them same values i set in the initial create call.

Yep, I’ve got it to work. How are you sending in the waypoint?

I have a node wrapper around the c sdk… i.e. non managed code. I just want to send the one waypoint. The object id is being passed in and definitely maps to an AI aircraft created with AICreateNonATCAircraft. My core code below, can you post what works for you?

Waypoint list data def…

SimConnect_AddToDataDefinition(ghSimConnect, WAYPOINTDEF, "AI WAYPOINT LIST", "Number", SIMCONNECT_DATATYPE::SIMCONNECT_DATATYPE_WAYPOINT);

Main call…

SIMCONNECT_DATA_WAYPOINT wp[1];
	
	wp[0].Latitude = json->Get(latProp)->NumberValue(ctx).ToChecked();
	wp[0].Longitude = json->Get(lngProp)->NumberValue(ctx).ToChecked();
	wp[0].Altitude = json->Get(altProp)->NumberValue(ctx).ToChecked();
	wp[0].Flags = SIMCONNECT_WAYPOINT_SPEED_REQUESTED;
	wp[0].ktsSpeed = json->Get(iasProp)->NumberValue(ctx).ToChecked();

	int objectId = args[1]->Int32Value(ctx).ToChecked();

	HRESULT hr = SimConnect_SetDataOnSimObject(ghSimConnect, WAYPOINTDEF, objectId, 0, ARRAYSIZE(wp), sizeof(wp[0]), &wp);
	if (NT_ERROR(hr))
	{
		handle_Error(isolate, hr);
		return;
	}

	args.GetReturnValue().Set(v8::Boolean::New(isolate, SUCCEEDED(hr)));

SIMCONNECT_DATA_WAYPOINT[] waypoints = new SIMCONNECT_DATA_WAYPOINT[2];

waypoints[0].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
waypoints[0].Altitude = alt;
waypoints[0].Latitude = startLat;
waypoints[0].Longitude = startLon;
waypoints[0].ktsSpeed = speed;

waypoints[1].Flags = (uint)(SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED | SIMCONNECT_WAYPOINT_FLAGS.WRAP_TO_FIRST);
waypoints[1].Altitude = alt;
waypoints[1].Latitude = endLat;
waypoints[1].Longitude = endLon;
waypoints[1].ktsSpeed = speed;

Object[] waypointsPolyArray = new Object[waypoints.Length];
waypoints.CopyTo(waypointsPolyArray, 0);

_sim.SetDataOnSimObject(Definitions.AIWaypointList, objID, SIMCONNECT_DATA_SET_FLAG.DEFAULT, waypointsPolyArray);

Hmm ok - so really the 2 differences… managed code and more than 1 waypoint. Will try the later and see what happens!

Working here too (managed code), but only the first time. I can send an entire route to an object or plane once, but it seems to ignore subsequent updates when I want to change the route of this object.

Thanks for the response - for me with non managed code - i got it to work if the aircraft is on the ground. It will follow waypoints and accept updates. But if i start the aircraft in the air - waypoints are ignored completely.

Confirmed, same here. Aircraft just fly straight ahead forever.

I was wrong earlier, I had my aircraft all flying, and didn’t realize that they don’t follow their route at all.

Can you tell me how to set waypoints in C# SIMCONNECT?
this is my attempt, with no result , plane on the ground (A320)

// “AI WAYPOINT LIST”
simconnect.AddToDataDefinition(DEFINITIONS.WaypointDef, “WAYPOINT LIST”, “number”, SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);
SIMCONNECT_DATA_WAYPOINT[] waypoints = new SIMCONNECT_DATA_WAYPOINT[2];

        waypoints[0].Latitude = 33.8652996221199;
        waypoints[0].Longitude = -118.03444644824;
        waypoints[0].Altitude = 2000;
        waypoints[0].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
        waypoints[0].ktsSpeed = 210;

        waypoints[1].Latitude = 33.8652996221199;
        waypoints[1].Longitude = -118.03444644824;
        waypoints[1].Altitude = 2000;
        waypoints[1].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
        waypoints[1].ktsSpeed = 250;

        Object[] objv = new Object[waypoints.Length]; waypoints.CopyTo(objv, 0);

        simconnect.SetDataOnSimObject(DEFINITIONS.WaypointDef, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, objv);           
    }

    public SIMCONNECT_DATA_WAYPOINT[] waypoints = new SIMCONNECT_DATA_WAYPOINT[2];

I am pretty sure that you can’t send waypoints to your own vehicle (OBJECT_ID_USER). This procedure only works on AI objects that your client program has created. Try the “ASO_Shuttle_01_Gray”, at least that bus is really moving - not all objects that you can create actually move, even when they are in a vehicle category. Especially moving aircraft can be tricky, they don’t seem to be able to taxi on ground. And when they fly, they fly badly. You can’t change their route when they are under way, that hasn’t changed. Don’t expect the level of sophistication that we had with FSX, let alone P3D.

1 Like