How to switch to AI traffic views (via SimConnect)?

kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

How to switch to AI traffic views (via SimConnect)?

Postby kwb » Thu Jun 21, 2018 8:55 am

When I add AI traffic I have views for each aircraft under "AI traffic". How can I switch to that view from SimConnect. Adding AI like this:

Code: Select all

const HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, qPrintable(modelString), qPrintable(callsign.toQString().left(12)), initialPosition, requestId);
gives me something like the "model description" + callsign as menu entry, e.g. "COMMERCIAL JET - DAMBZ". I have tried to switch to that view by "building" that string

Code: Select all

const QString viewName = "Commercial Jet-" + callsign.asString(); const char *view = viewName.toLatin1().constData(); HRESULT hr = SimConnect_ChangeView(m_hSimConnect, view);
I have tried some permutations like "callsign only", spaces around the "-" (hyphen/dash) etc. Does anybody know how what would be correct or even better how to obtain the correct view name at runtime?

obinder
Posts: 144
Joined: Sun Jun 08, 2014 9:43 am

Re: How to switch to AI traffic views (via SimConnect)?

Postby obinder » Sun Jun 24, 2018 5:34 pm

The Ai aircraft that you created cannot be called with a view name.
The "view name" in the method that you are using would be the camera definition looking at the AI. By default that is "AI Planes", category "Airtraffic", and the individual aircraft are "sub views" of that camera definition (so to speak).

I have already implemented this in two of my commercial and one freeware product, and from my experience this still requires complex logic. Expect a significant effort until you find a suitable method. There is still hope that this will be made easier in one of the next simulator versions.

Make sure to take a look at the Observers too. That logic is very powerful and might fill your need.

Best regards
Oliver Binder
Lorby-SI

kwb
Posts: 10
Joined: Tue Aug 28, 2012 9:16 pm

Re: How to switch to AI traffic views (via SimConnect)?

Postby kwb » Tue Jun 26, 2018 2:09 pm

Thanks for the info. I was wondering if there is a workaround which makes it possible to read all P3D menu entries and trigger those.

obinder
Posts: 144
Joined: Sun Jun 08, 2014 9:43 am

Re: How to switch to AI traffic views (via SimConnect)?

Postby obinder » Thu Jul 05, 2018 10:32 am

If I had to do it again, and knew that is was only for P3D v4.x, I would just read all the AI traffic with SimConnect as usual, and when the user selects a particular aircraft, create an Observer that is attached to the AI and looking at it. To move the camera I would implement my own controls, and adjust the attachment point on the target according to the users actions.

Check the Learning Center -> SDK -> SimConnect API -> References -> View Functions -> Observer Specific Functions

Best regards
Oliver Binder
Lorby-SI


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 13 guests