5.4 C++ Component getting collision pointer

#1
Welcome. I tried to get objects colliding with each other in new component system, but no way.
I obviously used

Code: Select all

virtual uint64 GetEventMask() const override { return BIT64(ENTITY_EVENT_START_GAME) | BIT64(ENTITY_EVENT_UPDATE) | BIT64(ENTITY_EVENT_COLLISION); }
and I am trying to catch collision event like this:

Code: Select all

virtual void ProcessEvent(SEntityEvent &event) override { if (event.event) { //Collision is being catched properly } }
So I managed to get this work. The only bad thing is I can't get collider !
In previous system in IGameObjectExtension there was HandleEvent method that had SGameObjectEvent parameter, and this parameter had pointer to the collider.

Code: Select all

event.ptr
Current ProcessEvent has only SEntityEvent parameter, which does not have any sort of pointer. How Do I get collider then? I tries nParam to see if any of 4 slots of this array returns maybe entityId, but nope.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: 5.4 C++ Component getting collision pointer

#2
Figured out! If anyone is looking for solution there it is.. Getting collision in ProcessEvent method:

Code: Select all

void ProcessEvent(SEntityEvent& event) override { switch (event.event) { case ENTITY_EVENT_COLLISION: { EventPhysCollision *physCollision = reinterpret_cast<EventPhysCollision *>(event.nParam[0]); if (physCollision) { IPhysicalEntity *pThisEntityPhysics = physCollision->pEntity[0]; IEntity *pThisEntity= gEnv->pEntitySystem->GetEntityFromPhysics(pColliderPhys); IPhysicalEntity *pColliderPhysics= physCollision->pEntity[1]; IEntity *pCollider = gEnv->pEntitySystem->GetEntityFromPhysics(pThisPhys); //Now just check if the collider entity is valid if(pCollider) { //Do something to your collider } } } break; } }
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Who is online

Users browsing this forum: No registered users and 1 guest