Cryengine 5.4 Questions about EntityComponents

1. What setup is necessary for Entity Component registration for it can be accessible in C++ code? To define method

Code: Select all

 static void ReflectType(Schematyc::CTypeDesc<YourComponentClass>& desc)

or we also need to register it with help of CRY_STATIC_AUTO_REGISTER_FUNCTION (As I think, this is needed for it to work with schematyc)?

2. What is the difference between functions CreateComponent and CreateComponentClass?

Re: Cryengine 5.4 Questions about EntityComponents

Now I have some weird problem and I just can't solve it. I have characters, which fight one another by swords. Characters are represented as a PE_LIVING entities and swords as a PE_RIGID.
When I try to get a pointer to a physical entity of the character, who is hit by the sword, from the sword collision event like this

Code: Select all

EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.nParam[0]);
IPhysicalEntity* pOtherEntityPhysics = pCollision->pEntity[1];
pOtherEntityPhysisc()->GetName(); //access violation exception

I get access violation exception. But in 5.3 this works just fine and with the same approach I can access an entity of a character from sword collision event (Cha-rs also have shields and when I try to get pointer to a shield entity, all works fine).
Here is how my characters are physicalized:

Code: Select all

   SEntityPhysicalizeParams physParams;
   physParams.type = PE_LIVING;

   physParams.mass = m_pSoldier->m_mass;

   pe_player_dimensions soldierDimensions;
   soldierDimensions.bUseCapsule = 1;

   soldierDimensions.sizeCollider = Vec3(0.34f, 0.01f, m_pSoldier->m_soldierEyeHeight * 0.3f);
   soldierDimensions.heightPivot = 0.f;
   soldierDimensions.heightCollider = 1.1f;
   soldierDimensions.groundContactEps = 0.004f;

   physParams.pPlayerDimensions = &soldierDimensions;

   pe_player_dynamics soldierDynamics;
   soldierDynamics.kAirControl = 0.f;
   soldierDynamics.mass = physParams.mass;

   physParams.pPlayerDynamics = &soldierDynamics;


   pe_params_collision_class collClass;

   SCollisionClass soldier(EEntitiesCollisionTypes::eET_ENEMY_ACTOR, EEntitiesCollisionTypes::eET_ENEMY_ACTOR | EEntitiesCollisionTypes::eET_ENEMY_WEAPON); //problem is not here, collision types are setted up properly

   collClass.collisionClassAND = soldier;
   collClass.collisionClassOR = soldier;


and my weapons:

Code: Select all

   SEntityPhysicalizeParams physParams;
   physParams.type = PE_RIGID;
   physParams.mass = 7.f;


   pe_params_collision_class collClass;

   SCollisionClass sword(collisionType, collisionIgnore);

   collClass.collisionClassAND = sword;
   collClass.collisionClassOR = sword;
   if (!collide) {
      pe_params_part pp;
      pp.flagsOR = geom_no_coll_response;

      GetEntity()->GetPhysicalEntity()->SetParams(&pp, 1);

Please help me and if I described this problem not enough clearly, say it and ask questions, because it kills me and I just can't find the solution.
Why sword entity doesn't have pointer to a PE_LIVING entity, which it collides with, but have pointer to the other's rigid entity in collision event?

Re: Cryengine 5.4 Questions about EntityComponents

Thank you. But problem was in other thing. I don't know if this is a bug, but when you set mass bigger than 0 to an entity, which is attached to character's skeleton by joint attachment, proxy of the entity's geometry constantly falling down and returning to it's original position. And problem was, that the proxy actually wasn't colliding with character's capsule. And, maybe, I should mention it in my post, but I thought, that this is just a proxy rendering bug. But when I set my sword's mass to 0, the problem was solved.

Who is online

Users browsing this forum: No registered users and 2 guests