Attach that object to the attachment of local player?

#1
Hi.

Can you tell me, how can i attach this light to the "#camera" attachment of local player ?

As you see, this is in action map(PlayerInput.cpp).

I hope, you answer as soon as possible by the permission of ALLAH...

Code: Select all

bool flashlighttoggleboolean = false; bool CPlayerInput::OnActionFlashlightToggle(EntityId entityId, const ActionId& actionId, int activationMode, float value) { const string& name = "flashlight"; IEntity* pEntity = gEnv->pEntitySystem->FindEntityByName(name.c_str()); //EntityId flightId = pEntity ? pEntity->GetId() : EntityId(0);//light id? //ActivateOutput(pActInfo, eOP_EntityId, pEntity ? pEntity->GetId() : EntityId(0)); if (flashlighttoggleboolean == false) { if (!m_pPlayer->IsDead()) { if (!pEntity) { flashlighttoggleboolean = true; CryLogAlways("Fanar yandi"); string className("Light"); string name("flashlight"); Vec3 pos(Vec3(0, 0, 32)); Vec3 rot(Vec3(0, 0, 0)); Vec3 scale(Vec3(1, 1, 1)); // Define SEntitySpawnParams params; params.nFlags = ENTITY_FLAG_SPAWNED; params.pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(className.c_str()); params.sName = name.c_str(); params.vPosition = pos; params.vScale = scale; Matrix33 mat; Ang3 ang(DEG2RAD(rot.x), DEG2RAD(rot.y), DEG2RAD(rot.z)); mat.SetRotationXYZ(ang); params.qRotation = Quat(mat); IEntity* pEntity = gEnv->pEntitySystem->SpawnEntity(params); //Attach light by the permission of ALLAH. } } } else if(flashlighttoggleboolean == true) { CryLogAlways("Fanar kecdi"); flashlighttoggleboolean = false; }; return false; }

Re: Attach that object to the attachment of local player?

#2
parent child attachment:

IEntity* pChild ;
pEntity->AttachChild(pChild);
pEntity->DetachThis(0, ENTITY_XFORM_TIMEDEMO);

entity slot :
LoadGeometry;
LoadCharacter;
LoadGeomCache;
LoadParticleEmitter;
LoadLight;
LoadVolumeObject
SetSlotLocalTM
SetParentSlot

skeleton bone attachment:

ICharacterInstance *pCharInst = deviceEnt ? deviceEnt->GetCharacter(0) : NULL;
IAttachment *pAttachment = pCharInst->GetIAttachmentManager()->GetInterfaceByName("handle");
CEntityAttachment *pEntityAttachment = new CEntityAttachment();
pEntityAttachment->SetEntityId(tickEnt);
pAttachment->AddBinding(pEntityAttachment);

SetupEntityAttachmentBinding;

check AttachmentUtils.cpp Entity.cpp

Who is online

Users browsing this forum: No registered users and 1 guest

cron