SimConnect Transmit Client Event not working for external sim object

zamirk
Posts: 97
Joined: Mon Jul 21, 2014 8:39 am

SimConnect Transmit Client Event not working for external sim object

Postby zamirk » Wed Dec 26, 2018 9:14 am

Hi,
I am creating an external simulated object as an Avatar and trying to transmit it's event for movement. I have mapped it's client events and keys respectively.Object gets created but when trying to move, it doesn't.

Below are code snippets with comments

//creating sim object
hr = SimConnect_AICreateSimulatedObject(hSimConnect, "Soldier Jungle", Init, EVENT_CREATE_SOLDIER);


// turn the input events on
hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_ZX, SIMCONNECT_STATE_ON);


//receiving object ID

case SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID:
{
SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *pObjData =(SIMCONNECT_RECV_ASSIGNED_OBJECT_ID*)pData;

switch( pObjData ->dwRequestID)
{

case EVENT_CREATE_SOLDIER:
AvatarID = pObjData->dwObjectID;
printf("\n Avatar id = %d", AvatarID );
break;
}
}

// Set up some private events
hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_JUMP);

// Add the private events to a notification group
hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_0, EVENT_JUMP);

// Set a high priority for the group
hr = SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP_0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);

// Map input events to the private client events
hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_JUMP, "j", EVENT_JUMP);

// transmitting on receive event

case SIMCONNECT_RECV_ID_EVENT:
{
SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;

switch(evt->uEventID)
{
case EVENT_JUMP:
hr = SimConnect_TransmitClientEvent(hSimConnect, AvatarID ,INPUT_JUMP,0,GROUP_0,false)
break;
}
}

Any one who has encountered the same ??

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

Re: SimConnect Transmit Client Event not working for external sim object

Postby obinder » Thu Dec 27, 2018 7:21 am

There is a topic about this, "Avatar Control", a few lines down from yours.

https://www.prepar3d.com/forum/viewtopi ... 0&t=131585

LM says that the procedure described in there should work for sim objects too, but in my experience it doesn't. Those commands only work on your own Avatar.

The only chance I had to implement this was to write a programmatic animation controller and to clone the Avatar MDL to a new simobject where I can trigger the animations myself.

Best regards
Oliver Binder
Lorby-SI

zamirk
Posts: 97
Joined: Mon Jul 21, 2014 8:39 am

Re: SimConnect Transmit Client Event not working for external sim object

Postby zamirk » Thu Dec 27, 2018 7:55 am

Thanks for your reply
I went through the topic you have suggested the problem still seems the same and i have done the same as explained there.
The only chance I had to implement this was to write a programmatic animation controller and to clone the Avatar MDL to a new simobject where I can trigger the animations myself.

any luck with the above ?

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

Re: SimConnect Transmit Client Event not working for external sim object

Postby obinder » Thu Dec 27, 2018 8:55 am

Thanks for your reply
I went through the topic you have suggested the problem still seems the same and i have done the same as explained there.
The only chance I had to implement this was to write a programmatic animation controller and to clone the Avatar MDL to a new simobject where I can trigger the animations myself.

any luck with the above ?
The events described in the thread definitely work if you send them to your own object. They do nothing if you send them to an Avatar that was created as an AI object.

any luck with the above ?
Yes, I have written my own animation controller a few months back, rooted in SimConnect alone. But you need someone proficient in modelling too, because you have to recompile the MDLs to change the Avatar animation definitions to your own custom logic. Figuring this whole procedure out is an effort of 40-80 hours, depending on your skill level and experience.
This seems hardly worth the effort, considering that LM says that the aforementioned events are supposed to work. So I understand that it is a bug in P3D that they don't (?)

Best regards
Oliver Binder
Lorby-SI


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 1 guest