Friday, May 6, 2016

unreal 4 - Error detecting collision with another instance of the same actor?


I have a project where after a certain time interval 2 NPCs are generated in different locations on the map.


Each of them collides with a collision box that defines its "class" (red or blue):


enter image description here


When 2 NPCs collide it was to be verified a condition (if the "class" of the involved ones is different) and from there both are destroyed, but nothing happens:


enter image description here


I put a print right after the Cast To NPC to see if it was happening and when they are generated the impression appears four times.


Blueprint:



enter image description here


Result in game:


enter image description here


I'd like to know how to set a cast only between two instances of the same actor.


Image showing that nothing happens when it (two instances of the same actor) collide:


enter image description here


I did the test with both codes (printing and destroying both).




EDIT 1 (I was being redundant)


In the code of destruction, I can simply put it to destroy itself only, because as it will run in both instances, the two will destroy themselves:



enter image description here


I'd still like to know how to correctly detect the collision between two instances of the same actor, but now I know that the code will be running twice, once in instance A and again in instance B.



Answer



As I've said before, it's important to be careful about redundancies.


At generation time it is only to define a warrior variable in two different ways:


enter image description here


And make this comparison so that the overlapping is only detected when desired:


enter image description here


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...